Well, that depends on how you want to get to the next page.
For instance you can do something like this, provided that this validation happens as the very first item in the document (e.g. there is no HTML or whitespace before the opening <?php delimiter).
Code:
<?php
if(isset($_POST["continue"]) )
{
if(empty($_POST["name"]))
{
$error = "Fill Up The Name ";
}
if (!isset($error))
{
// Store data here
// Then go on to the next page
header('Location: /path/to/next/page.php');
}
}
?>
You should do something with the data before continuing on to next page, like store it in a database or session, otherwise that data will be lost.
Code:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<br>
<br>
Name :
<input type="text" name="name">
<?php
if (isset($error))
{
echo $error;
}
?>
<br>
<br>
<input type="submit" name="continue">
</form>
For portability reasons you should avoid using the short tags "<?", and use the standard "<?php" as the opening delimiter.
HTH!
Regards,
Rich
--
[
http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design