|
-
Feb 8th, 2008, 11:28 AM
#1
Thread Starter
Addicted Member
Validating Form
I wish to check validation of the form by PHP (without Java script).
But if the form doesn't validate, I can redirect the page by
PHP Code:
header("Location: Myform.php");
this code.
But all form fields will be reset on that time.
So that page will not be a user friendly.
If I can post data automatically to Myform.php I can do this simply!
Most of the sites have the technology what I like. But I don't know how to do that!
Can you help me to fulfill my desire please?
If above question or answer will help to you
Don't forget to rate me
தமிழ்இன்பன்
-
Feb 9th, 2008, 02:58 AM
#2
Re: Validating Form
Just fill out the form fields using PHP.
PHP Code:
<input name="field1" value="<?php echo $field1 ?>">
Make sure that you have validated $field1 first and used the htmlentities or htmlspecialchars functions.
-
Feb 10th, 2008, 12:56 PM
#3
Thread Starter
Addicted Member
Re: Validating Form
This is my sample form
FormPage:
PHP Code:
<html> <head> <title>Validating Form</title> </head> <body> <form action="ValidatingPage.php" method="POST"> <P><strong>Your age:</strong><br><input name="yage" type="text" value="<?php echo($yage);?>"></P> <input name="" type="submit"> </form> </body>
Validating Page:
PHP Code:
<?php if (!$_POST[yage]|| $_POST[yage]<13) { $yage=htmlspecialchars($_POST[yage]); header("Location: FormPage.php"); exit; } else echo("Form Checked");
?>
Am I correct?
But Sorry, it is not working.
I think I must have made a mistake. But I don't know it!
Can you able to guess it?
If above question or answer will help to you
Don't forget to rate me
தமிழ்இன்பன்
-
Feb 15th, 2008, 08:50 AM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|