Terfanda Posted June 19, 2006 Share Posted June 19, 2006 [img src=\"style_emoticons/[#EMO_DIR#]/excl.gif\" style=\"vertical-align:middle\" emoid=\":excl:\" border=\"0\" alt=\"excl.gif\" /] [code] function CreateForm() { print("<form action=\"Petition.php\" method=post>\n"); print("First Name :<input type=text name=\"fname\" size=24 maxlength=32>"); print(" Last Name :<input type=text name=\"lname\" size=24 maxlength=32><br>\n"); print(" Email :<input type=text name=\"mailaddress\" size=30 maxlength=60><br>\n"); print("<input type=hidden name=\"BeenSubmitted\" value=\"TRUE\"><br>\n"); print("<input type=submit name=\"submit\" value=\"Submit\"></form>\n"); } function emailcheck($Email) { if(!ereg("^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$Email)) { //err.=$Email."is not a valid email address.<br/>"; $ans=FALSE; }else{ $ans=TRUE; } return $ans; } function check_forFileds($Name,$FamName,$Email) { if((!$Name)||(!$famName)||(!$Email)) { print("Invalid Input\n"); $ans=FALSE; } else{ $ans=TRUE; } return $ans; } function HandleForm() { $Name=$_POST['fname']; $FamName=$_POST['lname']; $Email=$_POST['mailaddress']; $TheDate=date("j F Y H:i:s"); $acc=emailcheck("$Email"); $acc=check_forFileds("$Name","$FamName","$Email"); if ($acc==TRUE) { $CallFunction=WriteToFile("$Name","$FamName","$Email","$TheDate"); } else { print("Please enter a valid Input !\n"); } } if(!isset($_POST['BeenSubmitted'])) { HandleForm(); } CreateForm(); ?>[/code]I am new athis when i run it it is giving me this errors:Notice: Undefined index: fname in ->$Name=$_POST['fname'];Notice: Undefined index: lname in ->$FamName=$_POST['lname'];Notice: Undefined index: mailaddress in ->$Email=$_POST['mailaddress'];Warning: ereg(): REG_BADRPT in ->if(!ereg("^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$Email))I Appreciate your help thank you in advance[b]EDITED BY WILDTEEN88: PLEASE USE THE CODE TAGS WHEN SUBMITTING BLOCKS OF CODE[/b] Link to comment https://forums.phpfreaks.com/topic/12410-help-in-validating-form/ Share on other sites More sharing options...
wildteen88 Posted June 19, 2006 Share Posted June 19, 2006 I think this:if(!isset($_POST['BeenSubmitted']))should be:if(isset($_POST['BeenSubmitted']))As currently it is validating form input when the form hasn't been submitted yet! Thats why you are getting the undefind index notices. Link to comment https://forums.phpfreaks.com/topic/12410-help-in-validating-form/#findComment-47450 Share on other sites More sharing options...
Terfanda Posted June 19, 2006 Author Share Posted June 19, 2006 [!--quoteo(post=385783:date=Jun 19 2006, 10:54 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 19 2006, 10:54 PM) [snapback]385783[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think this:if(!isset($_POST['BeenSubmitted']))should be:if(isset($_POST['BeenSubmitted']))As currently it is validating form input when the form hasn't been submitted yet! Thats why you are getting the undefind index notices.[/quote]First of al thank you i did wut you said an i got a new errorWarning: ereg(): REG_BADRPT if(!ereg("^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$Email))can you please tell me my mistake Link to comment https://forums.phpfreaks.com/topic/12410-help-in-validating-form/#findComment-47457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.