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
Post Variables without form
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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.
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.