Post Variables without form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
corin
Forum Newbie
Posts: 8
Joined: Mon Nov 04, 2002 3:07 am

Post Variables without form

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Why not include step2.php into step1.php if all the fields are correct?

Mac
corin
Forum Newbie
Posts: 8
Joined: Mon Nov 04, 2002 3:07 am

Post 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.
Post Reply