Posted by Erwin Moller on 09/21/07 13:33
Your Name Here wrote:
> Hi,
>
> Being new coding in phpI have a question concerning server side form
> validation.
>
> In a php script I check if a form is correctly filled in. Now I want that the
> page containing the forms is represented agian so that the user can fill in a
> correct value. The other forms that a correctly filled in should be showed
> agian.
>
> On the moment when a user fills in a wrong value they get a different page
> with a message...some that isn't tha usable. I want to represent the orginal
> form again.
>
> Thanks
Hi,
Simply put in the values in the form again.
A simple way to convey the idea:
From receiving PHP-script:
$url="http://www.example.com/myForm.php";
// do formchecking here
if ((isset($_POST["title"])) && (strlen($_POST["title"]) < 10)){
// title too short!
$url .= "?oldtitle=".urlencode($_POST["title"]);
header("Location: $url");
exit;
}
Then from the form-page:
<form action=".." Method="POST">
Title:
<input type="text" name="title" value="<?php echo
((isset($_GET["title"]))? $_GET["title"]: ""); ?>">
</form>
Simple example to show the idea.
If you want to send back multiple formelement, just add them together
with & (&).
Regards,
Erwin Moller
[Back to original message]
|