Hello ?
I am trying to validate the form and then if it fails, to re-display
the form with previous details so that the correct data is not lost.
The problem is that I need to increment $so_dat and $so_num
with $i , but I don’t know how to ? Or do I need a total re-write ?
ALSO when $so_num == ‘same’ I want it to be egual to the date that
was entered in the preceeding date – this saves re-typing the date each
time.
This is the process part called a_test.php
php
$a=1;
if(isset($_POST[‘sal_fm’])) { // BIG IF Means they filled in the form
for($i = 0; $i < 5; $i++){
$so_dat = strip_tags(trim($_POST[“so_dat$i”]));
$so_num = strip_tags(trim($
if($so_dat != ‘same’){
if(!ereg(“^[0-9]{2}––
$mess = “yes”;
$message1 = “Available date format must be dd-mm-yyyy”;
$message2 = “Please re-enter”;
require_once (“a_test_fm.php”);
exit();
} // endif
} // endif
else{
$j = $i-1;
$so_dat = strip_tags(trim($_POST[“so_dat$j”]));
/*
*
// update db
} // end else
} // end loop
} // end if END BIG IF
$today = date(U);
$so_dat = date(“d-m-Y”,$today);
require_once (“a_test_fm.php”);
AND HERE IS THE FORM ( CALLED a_test_fm.php )
<?php
if ($mess == “yes”) {
echo”
<div class = ‘head’ style=’position:absolute;left:130px; top:0px; font-size:16px;’>
<p><font color=’red’><b>ERROR: $message1<BR>$message2</b></font></p>
</div> “;
} // endif
?>
<div style=’position:absolute;left:200px; top:100px;’ >
<form action =’a_test.php’method = ‘POST’>
<input type=”hidden” name=”sal_fm” value=”yes” />
<table style=”width:150px; table-layout:fixed;” border = ‘0’ cellspacing = ‘2’ >
<?php
for($i=0;$i<5;$i++){
if($i >= 1){
$so_dat = “same”;
} // end if
echo ”
<tr>
<td><input type=’TEXT’ name=’so_dat$i’ value = ‘$so_dat’
size = ’10’ maxlength=’10’/></td>
<td><input type=’TEXT’ name=’so_num$i’ value = ‘$so_num’
size = ‘6’ maxlength=’10’/></td>
</tr>”;
} // end loop
?>
<tr>
<td ><input type=”submit” class=”btn_long” name = “batch” value = “Next Order”
onMouseover=”this.style.backgroundColor=’red'”
onMouseout=”this.style.backgroundColor=’yellow'” ></td>
</tr>
</table>
</form>
</div>
PLEASE HELP ME GET THIS WORKING – THANK YOU.
David