PDA

View Full Version : Remember me PHP Form Validation



chiefrebelangel
March 17th, 2007, 10:08 PM
Hey guys :bounce::bounce::bounce:

Im making a form which has quite many fieds, like 50 fields. The form is using php and i have a database to back it up. I made the necessary errortrapping needed to check for empty fields etc. I can save the values in database everything alright. Up to hear im alright. My problem is the following

When i entered the data and I submit the form an errormesage comes up (on a second page) and i provide a link using $_SERVER[HTTP_REFERER]; to go back, but the previous entered data is of course gone. I want it to stay there.

I dont want to make session variables cause its like over 50 fields, i have typed to many variables as it is ;)

I could of course use the PHPSELF but then I cant get my form to go to another page WHEN user managed to put all data correct.

I read about the header location function but i never get that to work due
to session already sent all the time GRRRRR.

Is it any person who can help me?:crying: please

I have googled for this without any luck, and searched various forums.

bwh2
March 18th, 2007, 01:39 PM
for starters, if your form is 50 fields, it should probably be spread across multiple pages. otherwise, that's just bad usability.

if you're typing in a lot of variables, you could probably benefit from using associative arrays instead. i think session variables is the way to go.

chiefrebelangel
March 18th, 2007, 03:30 PM
heya bwh2 =)

In my case the form with many fields has to be in one page and not really bad usability due to my customer needs a orderform which he writes by hand simply "copied" in electronic form to be able to put the data in electronically.

Well i guess it doesnt have any "easy" way of doing it than using session variables for each datafield, I checked out the associative array thing and I can see the pros of using it. Thanks for

One question. Couldnt i simply do the phpself form trick and do my errortrapping on the same page and then i can easy display errormessage on the same page, without saving session variables, and IF everything ok for the form to relocate to another page. Like i mentioned before I can never get this header location to work. I always get header already sent. can u use another way or relocate Automatically?:chinaman:

borrob
March 19th, 2007, 05:01 AM
Normally i do error checking in the client in javascript then you don't have the problem and
it's faster because you don't call the server. After checking the values i submit the form.
On the form i have a message div that tell's the user what's wrong

To do this you do:

<input onClick="check_insert()" type="button" name="insert" value="insert">

<script language="JavaScript">
<!--
function check_insert()
{
var message_obj = document.getElementById( "message" );
//check the values on the form:
if( your_form.some_value.value == "" )
{
message_obj.innerHTML = "some value must cannot be empty";
return;
}
your_form.submit();
}
//-->
</script>

chiefrebelangel
March 20th, 2007, 12:29 AM
hey borrob. :hugegrin:

sorry for my late reply, was stuck on 2 other websites! man I wish I could finish one at a time not 4 at the same, I will check out your suggestion. Im not really good in javascript but i try to get into it.

Thanks for the reply :thumb2: