Jump to content

PHP Cookies


craigeves

Recommended Posts

I have the following code as a .php file on my server. Everything works great... but now I want to be able to click on 'Click Here to tell us we can print your photo' button (yet to be created), and for it to remember the password inputed, open a new page with a form on it and paste the password into a text box so the user doesn't have to.

 

Can this be done without breaking the code below?

 

Many thanks

 

Craig

 

<?php
if (isset($_GET['image'])) {
    $path = "proofs/{$_GET['image']}.jpg";
    if (file_exists($path)) { //we're good
        printf('<div><p>Here is your photo for proofing:<p><img src="%s" alt=""/></div>', htmlentities($path, ENT_QUOTES));
          echo "Send your sales excecutive an email to confirm that your proof is OK to proof.<p>If you wish to proof another design please input the password below.
";
  }
    else {
        echo "<p>Image could not be found, please try again.</p>";
    }
}
//redisplay form anyway since it's easier than having to go back every time
?>
  
<p>To save  time we allow you to proof your designs online by entering your password in the form field below.</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
  <p>
    <input type="text" name="image" />
    </p>
  <p>
    <input type="submit" value="Submit" />
    </p>
</form>

Link to comment
Share on other sites

Why not just do this?

 

<?php
if ($_GET[check]){
if (isset($_GET['image'])) {
    $path = "proofs/{$_GET['image']}.jpg";
    if (file_exists($path)) { //we're good
        printf('<div><p>Here is your photo for proofing:<p><img src="%s" alt=""/></div>', htmlentities($path, ENT_QUOTES));
          echo "Send your sales excecutive an email to confirm that your proof is OK to proof.<p>If you wish to proof another design please input the password below.
";
  }
    else {
        echo "<p>Image could not be found, please try again.</p>";
    }
}
}else{
echo "You did not check the check boxe";
}
//redisplay form anyway since it's easier than having to go back every time
?>
  
<p>To save  time we allow you to proof your designs online by entering your password in the form field below.</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
  <p>
    <input type="text" name="image" size="20" />
    </p>
  <p>
    <input type="checkbox" name="check" value="ON"> click here for blah ...</p>
  <p>
    <input type="submit" value="Submit" />
    </p>
</form>

Link to comment
Share on other sites

Thanks for replying. I don't wish to do that as it is not what is required...

 

Let me explain a little further what I am after.

 

1. The above script shows an image when a password is inputed into the text field and the submit button is pressed. It searches the server for 'password'.jpg. Underneath the image the words 'Confirm that this image is OK to print' is displayed. Clicking on that will take you to a form on a seperate page.

 

2. The value of the password field on the previous page should be remembered and displayed in a new field on the new page.

 

I can do the rest from here, but I don't know how to get the above working + i don't want to break the code i am already using so it must be able to tie-in with the code above.

 

Can anyone else help?

 

Thanks in advance.

 

Craig

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.