First off, please know that I always try to spend at least a little time searching for answers before posting.
I am trying to figure out how to use php for validation and although I have found a few tutorials on this, i am not getting it. So if you don't mind, here's a couple of questions:
1) When validating via php, it seems that the action link in the form always refers back to the same page the form was on. Is this correct?
2) If question one is correct, then how do we finally move on to the next page once the data is correct? I read about a redirect somewhere. Is this how these are generally done? If so, is there a simply line of code someone can show on how to do a redirect.
Here is a basic (key word: BASIC) php file i made. Is this how the validation essentially works:
<html>
<body>
<?php
$submit = $_GET['submit'];
if ($submit) {
// some validation function that returns true if input is valid
// returns false if invalid
$valid = form_validate();
if ($valid) {
// process form (I guess redirect goes here.?. )
}
else {
$error = "Invalid input"; //obviously more details would be used
}
}
if (!$submit || $error) {
echo $error;
echo '<form method="post" action="<?php echo $PHP_SELF ?>">' . "\n";
// form STUFF
echo ' <input type="Submit" name="submit" value="Submit">' . "\n";
echo '</form>' . "\n";
}
?>
</body>
</html>
Thanks for your help.
Jonathan