zero-perfoliate
zero-perfoliate

Author Topic: getting the velidated form data on an other page  (Read 427 times)

Offline ramz

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
getting the velidated form data on an other page
« on: January 06, 2009, 10:13:06 PM »
 hi every one
                    i need help as i am very new to php .
  my question statement is as under.
    i have a html form having 4 input boxes
1= first name
2 =last name
3 =age
4 =phone number
i like that when teh user fil lin the form and submit the script ll check the form and validate it for example the user not inter the last name and in age input type words instead of numbers, in this case the form show error to the user and if all is ok then print or echo the thank you msg icluding the form data. for example.
user input
 1 , user name= ramz
 2 , last name= jee
 3 , age= 30
 4 , phone = 234567 some what like this.
 if there is no error
 the resulting page should show
   
                thank you for registring
          your first name= ramz
            your last name= jee
            your age = 30
           your phone = 23456
                                     
                                          helping answers ll be warmly welcomed.

Offline cajhne

  • New PHP Members
  • Posts: 3
  • Karma: +0/-0
Re: getting the velidated form data on an other page
« Reply #1 on: January 12, 2009, 03:46:39 AM »
Hi. You'll need to use JavaScript to validate your form if you want to validate before the submission takes place.

For example:

<SCRIPT type="text/javascript">
function submitForm()
{
   if(document.getElementById('FIRST_NAME').value=="")
   {alert("Sorry, you need to type in your name.");}
   else{document.FORM1.submit();}
}
</SCRIPT>

<FORM NAME="FORM1">
Enter your name: <INPUT TYPE="TEXT" NAME="FIRST_NAME" ID="FIRST_NAME">
<BR>
<INPUT TYPE="BUTTON" onClick="submitForm();" VALUE="SUBMIT">
</FORM>


If you click on the SUBMIT button, it pops up an error if you havn't entered in your name, otherwise it submits.
This example is pretty simple, but hopefully it gets you on the right track. :)

Cheers.



 

zero-perfoliate