Form isn't sending emails or displaying html upon submission
Posted: Mon Sep 26, 2011 11:03 am
I hate to ask but can some one do me a huge favor & look my form script over? I'm pretty new to php & I'm stumped. I've made a form within a html page which utilizes a second php file to validate the info & send it to me in an email. However, when I click submit it goes directly to a blank page & none of the e-mails are coming through. I placed the error reporting code in the beginning of the script & have work out a few errors line by line.. but nothing comes up for the issue at hand. I think I may have the html portion wrong. I've pasted the processing code below.. I'm sure it's just some newbie mistake on my part. Any help on this would be greatly appreciated.
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
// $Id: index.php,v 1.94 2007/12/26...
if(isset($_POST['email'])) {
$email_to = "ordietryingodt@yahoo.com";
$email_subject = "New Recruit To Add";
function died($error) {
// your error code can go here\par
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['QL_Name']) ||
!isset($_POST['Age']) ||
!isset($_POST['Country']) ||
!isset($_POST['Game_Type'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$QL_Name = $_POST['QL_Name']; // required
$Age = $_POST['Age']; // required
$Country = $_POST['Country']; // required
$Game_Type = $_POST['Game_Type']; // not required
$error_message = "";
$Country = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$QL_Name)) {
$error_message .= 'Please enter your residing country.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$Age)) {
$error_message .= 'Please enter you QL name.<br />';
}
if(!preg_match($string_exp,$Country)) {
$error_message .= 'Please enter your age.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\\n\\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "QL Name: ".clean_string($QL_Name)."\\n";
$email_message .= "Age: ".clean_string($Age)."\\n";
$email_message .= "Country: ".clean_string($Country)."\\n";
$email_message .= "Game Type: ".clean_string($Game_Type)."\\n";
?>
<!
</head>
<body background="diamondplate.jpg" alink="#c0c0c0" link="#c0c0c0" bgcolor="#000000"
text=#ffffff vLink=#c0c0c0><font size="1">
<p align="center">
<table border="0" cellspacing="0" cellpadding="3" width="100%" bgcolor="#000000"
align=center>
<tbody>
<tr>
<td>
<p align="center"><img border="0" hspace="0" src="ODTlogo1.gif" width="215"
height=89></p>
<p align="center"><img border="0" hspace="0" src="ODTlogo2.gif" width="192"
height=23></p></td></tr></tbody></table></p>
<p></font> </p>
<p align="center"><font size="5" face="Verdana"></font> </p>
<p align="center"><font size="5" face="Verdana"></font> </p>
<p align="center"><font size="5" face="Verdana">Thank you! We will send your clan
invite asap.</font></p>
<p align="center"><font size="5" face="Verdana">We look forward to fragging with
you.</font></p></body></html>
>
<?php
}
?>
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
// $Id: index.php,v 1.94 2007/12/26...
if(isset($_POST['email'])) {
$email_to = "ordietryingodt@yahoo.com";
$email_subject = "New Recruit To Add";
function died($error) {
// your error code can go here\par
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['QL_Name']) ||
!isset($_POST['Age']) ||
!isset($_POST['Country']) ||
!isset($_POST['Game_Type'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$QL_Name = $_POST['QL_Name']; // required
$Age = $_POST['Age']; // required
$Country = $_POST['Country']; // required
$Game_Type = $_POST['Game_Type']; // not required
$error_message = "";
$Country = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$QL_Name)) {
$error_message .= 'Please enter your residing country.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$Age)) {
$error_message .= 'Please enter you QL name.<br />';
}
if(!preg_match($string_exp,$Country)) {
$error_message .= 'Please enter your age.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\\n\\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "QL Name: ".clean_string($QL_Name)."\\n";
$email_message .= "Age: ".clean_string($Age)."\\n";
$email_message .= "Country: ".clean_string($Country)."\\n";
$email_message .= "Game Type: ".clean_string($Game_Type)."\\n";
?>
<!
</head>
<body background="diamondplate.jpg" alink="#c0c0c0" link="#c0c0c0" bgcolor="#000000"
text=#ffffff vLink=#c0c0c0><font size="1">
<p align="center">
<table border="0" cellspacing="0" cellpadding="3" width="100%" bgcolor="#000000"
align=center>
<tbody>
<tr>
<td>
<p align="center"><img border="0" hspace="0" src="ODTlogo1.gif" width="215"
height=89></p>
<p align="center"><img border="0" hspace="0" src="ODTlogo2.gif" width="192"
height=23></p></td></tr></tbody></table></p>
<p></font> </p>
<p align="center"><font size="5" face="Verdana"></font> </p>
<p align="center"><font size="5" face="Verdana"></font> </p>
<p align="center"><font size="5" face="Verdana">Thank you! We will send your clan
invite asap.</font></p>
<p align="center"><font size="5" face="Verdana">We look forward to fragging with
you.</font></p></body></html>
>
<?php
}
?>