Html Code (index.html)
<div id="stable" class="center-div" >
<form method="POST" action="send.php">
<input type="text" name="FNAME" value="FIRST NAME" size="20" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;">
<!--<input type="text" name="LNAME" value="LAST NAME" size="20" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;">-->
<input type="text" name="Email" VALUE="EMAIL" size="20" style="font-size:13px; height:50px; background-color:#f5f5f5"onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;">
<input type="submit" value="Submit" name="Submit" class="button">
</div>
</form>
Php code (send.php)
<?php
## CONFIG ##
# LIST EMAIL ADDRESS
$recipient = "admin@gmail.com";
# SUBJECT (Subscribe/Remove)
$subject = "Someone wants updates!";
# RESULT PAGE
$location = "index.html";
## FORM VALUES ##
# SENDER - WE ALSO USE THE RECIPIENT AS SENDER IN THIS SAMPLE
# DON'T INCLUDE UNFILTERED USER INPUT IN THE MAIL HEADER!S
$sender = $recipient;
# MAIL BODY
$body .= "Name: ".$_REQUEST['FNAME']."
";
$body .= "Email: ".$_REQUEST['Email']."
";
# add more fields here if required
## SEND MESSGAE ##
mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");
## SHOW RESULT PAGE ##
header( "Location: $location" );
?>
Thanks in advance for all replies!
There is a redirect once the mail is sent. Can you place your thank you message on this page? Sometimes I have a thank you.php page for this purpose.
Here is a snippet from a contact form to check for email validation will this help?
if(trim($_POST['email']) === '') {
} else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) {
$emailError = 'You entered an invalid email address.';
$hasError = true;
} else {
$email = trim($_POST['email']);
}
You could save the entries a database once submitted? Or I think you can create a session to keep hold of the variables for further use. What are you planning to do with the data then after it has been submitted?