Hey
im trying to make a form, that when submitted, checks the values the user entered, if they missed a field out, takes them back to form, displays a error message at the top, and inserts all the correctly entered values back into the various fields do the user dosnt have to fill it all back in. I've tried many ways, including the following...
<?php
$step = $_GET['step'];
if($step == "action"){
$field1 = $_POST['field1'];
$field2 = $_POST['field2'];
if(!empty($field1)){
if(!empty($field2)){
$g_message = "Success, fields full!";
}else{
$e_message = "Please enter a value into field2.";
}
}else{
$e_message = "Please enter a value into field1";
}
if(isset($g_message)){
?>
<html>
<head>
<title>Test</title>
</head>
<body>
<br>
<?php echo $page;?>
</body>
</html>
<?php
}else if(isset($e_message) || $step != "action"){
?>
<html>
<head>
<title>Test</title>
</head>
<body>
<br>
<?php echo $e_message;?>
<br><br>
<form action="<?php $_SERVER['PHP_SELF'];?>?step=action" method="post">
<input type="text" name="field1" value="<?php echo $_POST['field1'];?>">
<input type="text" name="field2" value="<?php echo$_POST['field2'];?>">
<input type="submit" value="Submit">
</body>
</html>
<?php
}
}
?>
...with no luck. Is it possible to do this by changing something in what i have tried above?
Thanks