View Full Version : PHP Form Not Emailing/Submiting
drummer392
February 11th, 2010, 07:37 AM
I have a form that should send to my email address (as it has always done in the past with the same form), but for some reason it is not at all.
Is there something wrong with my code, or my hosting service. I have used this code before with the same hosting services for a while now.
if(isset($_POST['submit'])) {
$to = myemail@yahoo.com
$body = "";
foreach($_POST as $name => $value)
{
$body .= "$name: $value";
mail($to, $subject, $body);
}
}
simplistik
February 11th, 2010, 08:33 AM
put quotes around the $to value
Dj-Studios
February 11th, 2010, 10:05 AM
$to = "my@email.com";
drummer392
February 11th, 2010, 11:57 AM
simple. thanks
drummer392
February 11th, 2010, 04:26 PM
Okay, so this is my code and it still isn't sending to me.
if(isset($_POST['submit'])) {
$to = "brandon@brandonrray.com";
$subject = "FORM";
$body = "";
foreach($_POST as $name => $value)
{
$body .= str_replace('_',' ',$name) . ":\n $value\n \n";
}
echo "<span class='text'>Thank You! Your message has been sent!</span>";
mail($to, $subject, $body);
} else {
echo "Sorry, your information was unsuccessful in the submission process! Please try again or contact the webmaster.";
}
drummer392
February 11th, 2010, 04:27 PM
Okay, so this is my code and it still isn't sending to me.
if(isset($_POST['submit'])) {
$to = "brandon@brandonrray.com";
$subject = "FORM";
$body = "";
foreach($_POST as $name => $value)
{
$body .= str_replace('_',' ',$name) . ":\n $value\n \n";
}
echo "<span class='text'>Thank You! Your message has been sent!</span>";
mail($to, $subject, $body);
} else {
echo "Sorry, your information was unsuccessful in the submission process! Please try again or contact the webmaster.";
}
drummer392
February 12th, 2010, 11:51 AM
I am using 1and1.com hosting service and I have contacted them about this issue because the same form works on a different hosting service.
Still, if I may be overlooking something, let me know
actionAction
February 12th, 2010, 12:13 PM
Try
if(!mail($to, $subject, $body)){
die("Message was not sent");
}
simplistik
February 12th, 2010, 03:14 PM
try not using
if(isset($_POST['submit']))
or at least don't make "submit" your button I'm sure currently you have
<form>
<!-- other form fields -->
<input type="submit" name="submit" value="Submit" />
</form>
try doing it with a hidden field
<form>
<!-- other form fields -->
<input type="hidden" name="submit" value="1" />
<input type="submit" value="Submit" />
</form>
then in your php instead of isset do
if ( $_POST['submit'] == 1 )
drummer392
February 12th, 2010, 05:14 PM
That didn't work either. I don't know why it's doing this. Hosting company said they couldn't get it to work either. Works on my other websites hosted by other companies.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.