Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?php
#########################################################
# #
#
PHP Form Validation/Mailer V-1.0
#
# #
# http://www.mainframe-webdesign.com #
# Copyright ¬ 2003. All Rights Reserved. #
# #
# This Copyright notice must stay in tact with script. #
#########################################################
/************************************************************
This script is for form validation to determine if all fields
have been filled out and if the email address supplied is of
valid syntax. If all statements return true then the form
is emailed to the specified recipient.
This script's main feature is that is replicates your form
for people if they missed a required fields. Any and all
fields that are missed show another form field, and those
that have been done properly show as normal text.
You will have to configure this to suit your needs. You will
also have to make sure that any input field names and hidden
field names reflect what you have on your form.
************************************************************/
##########################################################
/* First - Check to see if the email is of Valid Syntax */
##########################################################
$evalid=2;
if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$",$_POST["email"]))
{
$evalid=1;
}
else
{
$evalid=2;
}
###############################################################################################################
/* Second - Check to see if all fields have been filled in and make sure $evalid=1.
If a field is not filled in or an E-Mail address is of invalid syntax ($evalid=2) then show the field again. */
###############################################################################################################
if (eregi ("^$", $_POST["name"]) || eregi ("^$", $_POST["message"]) || $evalid =='2')
{
echo "<FORM NAME=\"contact\" ACTION=\"mail.php\" METHOD=\"POST\">\n";
echo "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"5\" WIDTH=\"401\">\n";
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"TOP\" COLSPAN=\"3\">ERROR!</TD></TR>\n";
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"TOP\" COLSPAN=\"3\">Please fill in the appropriate field(s)<BR><BR></TD></TR>\n";
if (eregi ("^$", $_POST["name"]))
{
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">Name:</TD><TD ALIGN=\"LEFT\" VALIGN=\"TOP\"><INPUT TYPE=\"text\" NAME=\"name\" SIZE=\"25\" MAXLENGTH=\"50\"></TD></TR>\n";
}
else
{
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">Name:</TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\" COLSPAN=\"2\">" . $_POST["name"] . "</TD></TR>\n";
echo "<INPUT TYPE=\"hidden\" NAME=\"name\" VALUE=\"" . $_POST["name"] . "\">\n";
}
if ($evalid == '2')
{
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">E-Mail:</TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\"><INPUT TYPE=\"text\" NAME=\"email\" SIZE=\"25\" MAXLENGTH=\"50\"></TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">Invalid E-Mail Syntax</TD></TR>\n";
}
else
{
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">E-Mail:</TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\" COLSPAN=\"2\">" . $_POST["email"] . "</TD></TR>\n";
echo "<INPUT TYPE=\"hidden\" NAME=\"email\" VALUE=\"" . $_POST["email"] . "\">\n";
}
if (eregi ("^$", $_POST["message"]))
{
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"TOP\">Message:</TD><TD ALIGN=\"LEFT\" VALIGN=\"TOP\" COLSPAN=\"2\"><TEXTAREA NAME=\"message\" COLS=\"50\" ROWS=\"15\"></TEXTAREA><BR><BR></TD></TR>\n";
}
else
{
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"TOP\">Message:</TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\" COLSPAN=\"2\">" . $_POST["message"] . "<BR><BR></TD></TR>\n";
echo "<INPUT TYPE=\"hidden\" NAME=\"message\" VALUE=\"" . $_POST["message"] . "\">\n";
}
echo "<TR><TD>á</TD><TD ALIGN=\"LEFT\" VALIGN=\"TOP\" COLSPAN=\"2\"><INPUT TYPE=\"SUBMIT\" VALUE=\"SEND\" onclick=\"contact.submit(); this.disabled = true; contact.RESET.disabled = true;\" CLASS=\"forminput\"><IMG SRC=\"/spacer.gif\" WIDTH=\"10\" HEIGHT=\"1\" ALT=\"\"><INPUT TYPE=\"RESET\" VALUE=\"CLEAR\" NAME=\"RESET\"></TD></TR>\n";
echo "</TABLE>\n";
echo "</FORM>\n";
}
######################################################################################################
/* Third - If all fields are filled out and the E-Mail is of valid syntax continue to mail the form */
######################################################################################################
else
{
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
$to = "email@site.com";
$subject = "Site message from: $name";
###############################################################
/* Fourth - This is how you format how you receive the email */
###############################################################
$body = "Name: $name\r\n";
$body .= "E-mail: $email\r\n\n";
$body .= "Message: $message\r\n";
$headers .= "From: ".($name)."<".($email).">\n";
##############################################################################################
/* Fifth - This shows a confirmation of what the user wrote and what the recipient will see */
##############################################################################################
if (@mail ($to, $subject, $body, $headers))
{
echo "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"5\">\n";
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"TOP\" COLSPAN=\"2\">Thanks!</TD></TR>\n";
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"TOP\" COLSPAN=\"2\">Your message was sent successfully<BR><BR></TD></TR>\n";
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">Name:</TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">$name</TD></TR>\n";
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">E-Mail:</TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">$email</TD></TR>\n";
echo "<TR><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">Message:</TD><TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\">$message</TD></TR>\n";
echo "<TR><TD ALIGN=\"LETT\" VALIGN=\"MIDDLE\" COLSPAN=\"2\"><INPUT TYPE=\"button\" VALUE=\"Finished\" onclick=\"window.location.href('main_page.html');\"></TD></TR>\n";
echo "</TABLE>\n";
}
####################################################################
/* Sixth - This will show if there was an error sending the email */
####################################################################
else
{
echo "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"5\">\n";
echo "<TR><TD>Error!<BR><BR></TD></TR>\n";
echo "<TR><TD>There was an error sending your form message. Please try again at a later time.</TD></TR>\n";
echo "</TABLE>\n";
}
}
###########
# END PHP #
###########
?>