Page 1 of 1

Post Variables without form

Posted: Thu Nov 14, 2002 3:00 am
by corin
Here's a common task. I have a form in step1.php

<form action="<?= $_SERVER['PHP_SELF']; ?>" method="post">

After input, step1.php checks the data fields - if empty, the user is prompted to put data into the empty fields.

Then, if the fields are ok, I want to go to step2.php automatically and post all variables also.
I've acheived this by cheating and adding a form button with hidden fields :
<FORM METHOD="POST" ACTION="mydomain/step2.php">

But this is a bit naff as the user needs to click once to submit data, then again to goto step2.php. Can somebody help me with this. I've dabbled with cURL which I've sort of got working, but not very well. Thanks

Posted: Thu Nov 14, 2002 3:08 am
by twigletmac
Why not include step2.php into step1.php if all the fields are correct?

Mac

Posted: Thu Nov 14, 2002 4:08 am
by corin
That's a valid point. Unfortunately the logic in my script doesn't like that approach. Step one is for entering user personal data. Step 2 is for uploading a photo.

The form for step one is displayed by if (!$submit).....{So, basically if it's not been submitted I display it. } else {check the fields for input}

The problem is if I have the upload in the same script it all goes pear shaped in that, when I upload the photo (using <form action="<?= $_SERVER['PHP_SELF']; just as it's about to upload, the page resets and displays the form again and not the photo. That is why I was cheating by having it as 2 separate steps.