form processing question

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
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

form processing question

Post by C_Calav »

hi guys, i got a question.

i got a submit page for users details and i can post that to the next page that has all the users mistakes on it - proccess.php - for example "you havent filled blank out correctly go back and fill out again" now my question is how would i go about going back to the submit form with the details STILL in there?

any help what so ever would be great! is this the best way to do it?

thanx
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Why not keeping it on the same page

Code: Select all

#with $_SERVER['PHP_SELF']
#example 
if(isset($_POST['submit']))
{		
	if(strlen($_POST['some'])>0)
	{
	$some ='1';
	}
	else
	{
	$some = '* You forgot Something';
	}

#than youre form would look like this

if($some == '1')
{
echo '<font size="2">Some<input type="text" name="'.$_POST['some'].'">';
}
else{ echo '<font size="2">Some<input type="text" name="some">'.$some.'';
}
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

i dont have too much room to play around with on that page. i did have it like that in the first place.

can i go back a page and still keep the users data in the submit form?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You can as long as you echo it back as the forms values of keep it in hidden fields. I always post my forms, check that everything is ok and if it isnt show an error message that has all the data hidden in a form on that error page. Then the user clicks a button to go back to the first form where the data they entered to begin with is placed into the form as the default field values.

Once you code this up into OO its very simple, and you dotn have to keep typing out the hidden forms and stuff.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

try adding this to the top of the page.

header("Cache-control: private");
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

I am wondering about youre methods kettle_drum can you post / send me a example ?
Post Reply