hi guys,i'm really stuck:
i have a form which has few parts,for each part i do error check like this:
(the flag value comes from hidden filed in the form :PHP Code:if (isset($_POST['flag'])) {
if (!ereg("^[a-zA-Z]+$", $firstName) || ($firstName=="")){
$e.="Please enter a valid Name<br>";
}
if (!ereg("^[a-zA-Z]+$", $lastName) || ($lastName=="")){
$e.="Please enter a valid Last name<br>";}
if (!(isValidEmail($email)) || ($email=="")){
$e.="Please enter a valid Email<br>";}
if ($countryOfResidence==""){$e.= "Please select Country of residence<br>";}
if ($phoneCountry==""){$e.= "Please select Phone country<br>";}
if (!is_numeric($areaCode) || $areaCode==""){$e.= "Please enter valid Area code<br>";}
if (!is_numeric($phoneNumber) || $phoneNumber==""){$e.= "Please enter valid Phone number<br>";}
if (!empty($e)){echo "<div class='error'>$e</div>";}
)Code:<input type='hidden' name='flag' value='1'>
then after all of the six error checks i put this code:
and indeed if the form is blank and submitted nothing happens and if all errors are empty and the form is not blank the message "thank you2" displayed.PHP Code:$ws='0';
if (isset($_POST['flag'])) {
$ws='1';
if(($e==""&&$e2==""&&$e3==""&&$e4==""&&$e5==""&&$e6=="")&&($ws=='0')){}
if (($e==""&&$e2==""&&$e3==""&&$e4==""&&$e5==""&&$e6=="") && ($ws=='1')){echo "<div style='float:left;' class='clean-ok'>thank you2</div>";}}
the problem is that i want to put this last code at the top and then transfer a redirect header to the browser,but if i do put the code at the top of the script it shows the "thank you2" at the top even if no submit was done.
any ideas how to solve this?
p.s. tried to echo to the html form hidden fileds like this:
and then check them,but it didnt work well too.HTML Code:if (!empty($e)){echo "<div class='error'>$e</div><input type='hidden' name='e1' value='1'>";}
p.s. sorry for english mistakes-3rd languge[not counting php html css asp vb c]



Reply With Quote

Bookmarks