Jump to content


Photo

Page Refresh , Email Validation


  • Please log in to reply
No replies to this topic

#1 Terfanda

Terfanda
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 19 June 2006 - 09:32 PM


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 (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $Email))
{
$ans1=TRUE;
}
else
{
$ans1= FALSE;
}
return $ans1;

}



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");
$acc1=check_forFileds("$Name","$FamName","$Email") ;

if (($acc==TRUE)AND($acc1==TRUE))
{
$CallFunction=WriteToFile("$Name","$FamName","$Email","$TheDate");
}

else
{
print("Please enter a valid Input !\n");
}

}

if(isset($_POST['BeenSubmitted']))
{
HandleForm();
}
CreateForm();

?>


The email check function is not wrorking correctly can someone help me or give me another funstion to check emails

this is the function

function emailcheck($Email)
{
if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $Email))
{
$ans1=TRUE;
}
else
{
$ans1= FALSE;
}
return $ans1;

}

it is called in this line :
$acc=emailcheck("$Email");

and checked for the answer in this line :
if (($acc==TRUE)AND($acc1==TRUE))
and each time i refresh the page the data on it is resend to the file how can solve it
if(isset($_POST['BeenSubmitted']))
{
HandleForm();
}
CreateForm();

?>

how can i reset the form after i submit it






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users