Jump to content

Archived

This topic is now archived and is closed to further replies.

Terfanda

Page Refresh , Email Validation

Recommended Posts


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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.