Page 1 of 1

Form Validation Mulitpage question - Please help me!!!

Posted: Sat Jul 25, 2009 11:32 am
by foot01
Hello -

I am new to PHP and I am building a muliti-page form. I'm having issues validating my form and submitting variables to the next page.

I am getting an error when it the form tries to validate - Notice: Undefined index: q01 on line 17

I have two questions:

1. How do I validate and send these vars to the next page?
2. The next form is called form02.php. Do I put that in the form action call?
ie. <form name="form1" method="post" action="form02.php">

Any help would be great!

Here is my example --->

<?PHP
// start session
session_start();

// check if radio button is selected after submit
if(isset($_POST['submit'])) {

if (!$_POST['q01'])
echo "Question 1 is required";
} else {

?>

<form name="form1" method="post">
Question One:
<input type="radio" name="q01" value="No" />No
<input type="radio" name="q01" value="Yes" />Yes
<input type="radio" name="q01" value="Maybe" />Maybe

<input type="submit" name="submit"value="Send">

</form>

<?php }

?>

Re: Form Validation Mulitpage question - Please help me!!!

Posted: Sat Jul 25, 2009 12:10 pm
by jackpf
You should use isset() if you don't want the error.

And what do you mean...you want to forward the user to another form?

Re: Form Validation Mulitpage question - Please help me!!!

Posted: Sat Jul 25, 2009 12:53 pm
by johniem
If you want to redirect the user to another form after the first one you have to do it after you proccess the users input .. So when the user submits the form you will
get the inputs at the server side, proccess the user's inputs and then you can display the new form to the client. You can to this at the same script like the form02.php you mention.
Php has some very nice form validation capabilities.Just search the net and you will find many of them.

Hope this helps.

Re: Form Validation Mulitpage question - Please help me!!!

Posted: Sat Jul 25, 2009 1:31 pm
by foot01
I'm doing a multi-page form - there are about 4 steps in the process.

I am not sure about the reply regarding process the variables first as mentioned above.

Can some elaborate more on this?

Re: Form Validation Mulitpage question - Please help me!!!

Posted: Sat Jul 25, 2009 1:36 pm
by jackpf
You need to do whatever you want to do with the posted data, and then redirect to the next form, I think was the jist of it.