Alright,

I'm planning on creating a script that generates a random image.

Example:

<head>
<title>Random Image Script Generator</title>
<style>
<!--
// style
-->
</style>
</head>
<body>
<?php
if(isset($_POST['submit'])) {
$rand = rand(10000,99999)*date(U); // Generate random digits and multiply it by timestamp
$fileName = $rand.".jpg";
// Create the random JPEG file
?>
<p><span class="error">The script was created successfully!</p>
<p><span class="code">&lt;img src="<?php echo $fileName; ?>"&gt;</span></p>
<?php
}
else {
?>
<form action="" method="POST">
<p>
Image 1 URL: <input type="text" name="image1" value="Your URL Here"><br>
Image 2 URL: <input type="text" name="image2" value="Your URL Here"><br>
Image 3 URL: <input type="text" name="image3" value="Your URL Here"><br>
<input type="submit" name="submit" value="Generate Script!">
</p>
</form>
<?php
}
?>

Basically, I want the script to take in the user's request to create an image that will change when the browser is refreshes (like, say, Random Signature Generator).
Then it would tell the user
Put this in your "signature": or <img src="file.jpg">
I want the script to be created in JPG form, though. Can I do that?

    file.php:

    <?php
    // make sure there are no spaces, newlines, or text before the <?php tag, then...
    
    header("Content-type: image/jpeg");
    
    // code that generates and outputs image....
    ?>
    

      If you want to run the script on the same file as the form, you can do something like this: (but it will only generate one image file me thinks...)

      <?php
      if(isset($_POST['submit'])) 
      {
      	// ... your script here ... //
      	exit;
      }
      else {
      ?>
      <html>
      <head>
      <title>Random Image Script Generator</title>
      </head>
      
      <body>
      <form action="" method="POST">
      <p>
            Your URL Here: <input type="text" name="image1" value="">
      </p>
      </form>
      </body>
      </html>
      <?php
      }
      ?>
      
        Write a Reply...