Graphicsgod
06-01-2007, 07:13 PM
I'm having problem with my email PHP form :mad:! I've been trying for a week now and nothing I've tried will send mail to my email!! What is it that I'm doing wrong?
I'm using Godaddy.com on a windows server. It works with both PHP and ASP, but ASP is preferred for a windows server. But all I've been getting is error or confirmation messages, but no email in my in-box! Is it me, or is it Godaddy.com?!?
Heres a sample of my form:
<div id="container">
<form id="form_4" name="sendmail" class="mail"
onsubmit="return validate_form_4(this)"
action="sendemail.php" method="post" target="_self">
<fieldset>
<legend> Personal Information </LEGEND>
<ul id="formFields">
<li><label class="desc" for="field17">Name:</label>
<span><input id="Fname" name="first_name" maxlength="200" class="field text"
size="14" class="memorize" value="" onkeypress="return handleEnter(this, event)"
onFocus="clearText(this)" />
<label class="tam">First</label></span>
<span><input id="Lname" name="last_name" maxlength="200" class="field text"
size="14" class="memorize" value="" onkeypress="return handleEnter(this, event)"
onFocus="clearText(this)" />
<label class="tam">Last</label></span>
<div id="hintanchor_1">
<a href="#" class="hintanchor"
onMouseover="showhint('Please type your (<b>REAL</b>) name.', this, event, '200px')">
<img src="images/about.gif" border="0" width="20" height="20" alt="" /></a>
</div>
</li>
<li>
<label class="desc" for="field8">Email:</label>
<div>
<input id="Email" name="email" maxlength="200" class="field text medium"
type="text" maxlength="255" class="memorize" value=""
onkeypress="return handleEnter(this, event)" onFocus="clearText(this)" />
</div>
<div id="hintanchor_2">
<a href="#" class="hintanchor"
onMouseover="showhint('Please input your (<b>REAL</b>) email address.', this, event, '150px')">
<img src="images/about.gif" border="0" width="20" height="20" alt="" /></a>
</div>
</li>
<li>
<label class="desc" for="field123">Attention:</label>
<div>
<select "id="Attnfield" name="Attn">
<option value=" General " selected="selected">General Message</option>
<option value=" Support ">Support</option>
<option value=" Sales/Billing ">Sales/Billing</option>
<option value=" Technical ">Technical</option>
</select>
</div>
</li>
<li>
<label class="desc" for="field124">Comments:
<i><font size="-2" color="#919090">(No More than <u>1,000</u> Characters
please.)</font></i></label>
<div>
<textarea id="Comments" name="text_box" rows="10" cols="50"
class="field textarea medium"
style="width: 370px; font-family: Arial; font-size: 13px; z-index: 14"
onKeyDown="textCounter(this,'progressbar1',1000)"
onKeyUp="textCounter(this,'progressbar1',1000)"
onFocus="textCounter(this,'progressbar1',1000)"></textarea>
<div id="progressbar1" class="progress"></div>
<script>textCounter(document.getElementById("maxcharfield"),"progressbar1",1000)</script>
</div>
</li>
</ul>
<div class="buttons">
<center>
<font size="1">
<input id="submit" name="submit" class="button" type="submit" value="Send Message" />
<img src="images/spacer.gif" width="20" height="2" alt="" />
<input id="reset" name="reset" class="button" type="reset" value="Reset Form">
</font>
</center>
</div>
</fieldset>
</form>
</div>
As you can see, it's just a simple HTML email form. Now the php code pages.
Ver. 1:
<?php
$to = 'mymail@gmail.com';
$name = $_POST['first_name'];
$name = $_POST['last_name'];
$email = $_POST['email'];
$subject = $_POST['attn'];
$message = $_POST['text_box'];
else {
$from = 'From: '.$name.' <'.$email.'>';
}
$subject = stripcslashes($subject);
$body = stripcslashes($message);
if(mail($to, $subject, $body, $from)){
echo "Mail ($subject), was successfully sent.";
}
else {
echo "The email ($subject) could not be sent.";
}
if(mail(mail(mymail@gmail.com, $name, $subject, $message)) { header("Location: thanks.htm"); //Sends to New Page
echo "<p>TEXT</p>"; // Prints out some text
}
else {
echo "<p>An Error Occured, Please Resend<p>"; }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>I.D. Tagem...Thanks!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- meta http-equiv="refresh" content="0;url=thanks.htm" -->
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
<br>Your message has been sent
<p><a href="<?php print $continue; ?>">Click here to continue</a></p>
</center>
</div>
</body>
</html>
Ver. 2:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<?php
if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($first_name) || empty($email) || empty($text_box )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$text_box = stripcslashes($text_box);
$message = " $todayis [EST] \n
Attention: $attn \n
Message: $text_box \n
From: $first_name ($email)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $email\r\n";
mail("mymail@gmail.com", $subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $first_name ?> ( <?php echo $email ?> )
<br />
Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $text_boxout = str_replace("\r", "<br/>", $text_box);
echo $text_boxout; ?>
<br />
<?php echo $ip ?>
<br /><br />
<a href="thanks.htm"> Next Page </a>
</p>
</body>
</html>
Can anyone see a problem with that code that would prevent it from sending?!? Minus the name thing (ie. can't find an example for both "first" and "last" names in a PHP form field), so if anyone knows how to correct that, please feel free to post the code!
If Godaddy.com doesn't allow PHP email forms for some odd reason, you think I would get better results with ASP? And if so, what would the code look like? I've been working with PHP forms for a month now, ASP is still new to me.
Thanks for your time and help, Rob.
I'm using Godaddy.com on a windows server. It works with both PHP and ASP, but ASP is preferred for a windows server. But all I've been getting is error or confirmation messages, but no email in my in-box! Is it me, or is it Godaddy.com?!?
Heres a sample of my form:
<div id="container">
<form id="form_4" name="sendmail" class="mail"
onsubmit="return validate_form_4(this)"
action="sendemail.php" method="post" target="_self">
<fieldset>
<legend> Personal Information </LEGEND>
<ul id="formFields">
<li><label class="desc" for="field17">Name:</label>
<span><input id="Fname" name="first_name" maxlength="200" class="field text"
size="14" class="memorize" value="" onkeypress="return handleEnter(this, event)"
onFocus="clearText(this)" />
<label class="tam">First</label></span>
<span><input id="Lname" name="last_name" maxlength="200" class="field text"
size="14" class="memorize" value="" onkeypress="return handleEnter(this, event)"
onFocus="clearText(this)" />
<label class="tam">Last</label></span>
<div id="hintanchor_1">
<a href="#" class="hintanchor"
onMouseover="showhint('Please type your (<b>REAL</b>) name.', this, event, '200px')">
<img src="images/about.gif" border="0" width="20" height="20" alt="" /></a>
</div>
</li>
<li>
<label class="desc" for="field8">Email:</label>
<div>
<input id="Email" name="email" maxlength="200" class="field text medium"
type="text" maxlength="255" class="memorize" value=""
onkeypress="return handleEnter(this, event)" onFocus="clearText(this)" />
</div>
<div id="hintanchor_2">
<a href="#" class="hintanchor"
onMouseover="showhint('Please input your (<b>REAL</b>) email address.', this, event, '150px')">
<img src="images/about.gif" border="0" width="20" height="20" alt="" /></a>
</div>
</li>
<li>
<label class="desc" for="field123">Attention:</label>
<div>
<select "id="Attnfield" name="Attn">
<option value=" General " selected="selected">General Message</option>
<option value=" Support ">Support</option>
<option value=" Sales/Billing ">Sales/Billing</option>
<option value=" Technical ">Technical</option>
</select>
</div>
</li>
<li>
<label class="desc" for="field124">Comments:
<i><font size="-2" color="#919090">(No More than <u>1,000</u> Characters
please.)</font></i></label>
<div>
<textarea id="Comments" name="text_box" rows="10" cols="50"
class="field textarea medium"
style="width: 370px; font-family: Arial; font-size: 13px; z-index: 14"
onKeyDown="textCounter(this,'progressbar1',1000)"
onKeyUp="textCounter(this,'progressbar1',1000)"
onFocus="textCounter(this,'progressbar1',1000)"></textarea>
<div id="progressbar1" class="progress"></div>
<script>textCounter(document.getElementById("maxcharfield"),"progressbar1",1000)</script>
</div>
</li>
</ul>
<div class="buttons">
<center>
<font size="1">
<input id="submit" name="submit" class="button" type="submit" value="Send Message" />
<img src="images/spacer.gif" width="20" height="2" alt="" />
<input id="reset" name="reset" class="button" type="reset" value="Reset Form">
</font>
</center>
</div>
</fieldset>
</form>
</div>
As you can see, it's just a simple HTML email form. Now the php code pages.
Ver. 1:
<?php
$to = 'mymail@gmail.com';
$name = $_POST['first_name'];
$name = $_POST['last_name'];
$email = $_POST['email'];
$subject = $_POST['attn'];
$message = $_POST['text_box'];
else {
$from = 'From: '.$name.' <'.$email.'>';
}
$subject = stripcslashes($subject);
$body = stripcslashes($message);
if(mail($to, $subject, $body, $from)){
echo "Mail ($subject), was successfully sent.";
}
else {
echo "The email ($subject) could not be sent.";
}
if(mail(mail(mymail@gmail.com, $name, $subject, $message)) { header("Location: thanks.htm"); //Sends to New Page
echo "<p>TEXT</p>"; // Prints out some text
}
else {
echo "<p>An Error Occured, Please Resend<p>"; }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>I.D. Tagem...Thanks!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- meta http-equiv="refresh" content="0;url=thanks.htm" -->
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
<br>Your message has been sent
<p><a href="<?php print $continue; ?>">Click here to continue</a></p>
</center>
</div>
</body>
</html>
Ver. 2:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<?php
if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($first_name) || empty($email) || empty($text_box )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$text_box = stripcslashes($text_box);
$message = " $todayis [EST] \n
Attention: $attn \n
Message: $text_box \n
From: $first_name ($email)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $email\r\n";
mail("mymail@gmail.com", $subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $first_name ?> ( <?php echo $email ?> )
<br />
Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $text_boxout = str_replace("\r", "<br/>", $text_box);
echo $text_boxout; ?>
<br />
<?php echo $ip ?>
<br /><br />
<a href="thanks.htm"> Next Page </a>
</p>
</body>
</html>
Can anyone see a problem with that code that would prevent it from sending?!? Minus the name thing (ie. can't find an example for both "first" and "last" names in a PHP form field), so if anyone knows how to correct that, please feel free to post the code!
If Godaddy.com doesn't allow PHP email forms for some odd reason, you think I would get better results with ASP? And if so, what would the code look like? I've been working with PHP forms for a month now, ASP is still new to me.
Thanks for your time and help, Rob.