Jump to content

Page Refresh , Email Validation


Terfanda

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.