i sort of fix the problem with displaying the form again when invalid data is entered ..Bascially what i program does is that getting the student to enter their student ID and their car registraton number, and choose from within the next five following day(counting from one day after the form being submited successfuly) eg if today is the 20th April, then there will be five check boxes with the date(21 April,22 April.....25 April) as the label the student can choose from . The student ID field must be 7 digits, and the registration field either 2 Upper case letter followed by 1 to 4 digitss or 3 UPPER CASE letter followed by 1 to 3 digits. below is a brief summy of my program.
<?php
if(count($_POST)>0){
$AUID=$_POST['stuID'];
$REGO=$_POST['regNO'];
//check the validity of the student ID
if(!preg_match("/^(\d{7})$/",$AUID)){
$IDNotValid=true; $field="AUID";
$AUID = "";
}
//check the validity of the registration number
if(!(preg_match("/^[A-Z]{2}[0-9]{1,4}$/",$REGO)||preg_match("/^[A-z]{3}[0-9]{1,3}$/",$REGO))){
$RegNotValid=true; $field="Registration Number";
$REGO="";
}
if($IDNotValid){
// display the form again,the stuID field would be empty in this case but with the correct registration number
//in the regNO field in the form
echo " some form data here"
}
if($RegNotValid){
// display the form again,the regNO field would be empty in this case but with the correct Student ID in the stuID field
echo "some form data here"
}
}
else{?>
[code=html]
<html>
<body>
<p>Welcome To Tamaki Online Car Park Booking System</p>
<form action="comboform.php" method="post" />
<input type="text" name="stuID" value="<?php echo $_POST['stuID'] ?>">
<input type="text" name="regNO" value="<?php echo $_POST['regNO']?>">
<input type="checkbox" name="dates[]" value="day1">
.
.
.
<input type="checkbox" name="dates[]" value="day5">
</body>
</html>
}
?>
[/code]
My question is when invalid info is provided , the form should keep displaying until the student have provided all the valid information. but how can i refer to the correct info entered previously by the student? thanks in advance