Jump to content

Problems with an HTML form


APC

Recommended Posts

Hi, I am using the following form on my website to allow the users to send an email directly to my account. The PHP code seems fine to me, yet it isn't working. When I press send I am being taken to that page called "thankhyou.html" which implies to me that the email has been sent, yet I am not receiving any emails. I have tried using a different email address, yet this makes no difference. I have also tried hosting the pages on another server WHICH I KNOW FOR SURE IS COMPATIBLE WITH THE LATEST PHP. Still I have had no luck. Does anyone have any ideas? 

<form action="mail.php" method="POST">

<table>

<tr><td>Name: </td><td><input type="text" name="name"></td></tr>

<tr><td>Email: </td><td><input type="text" name="email"></td></tr>

<tr><td>Subject: </td><td><input type="text" name="subject"></td></tr>

<td>Message: </td><td><textarea style="width: 200px; height: 90px; " name="message"></textarea></td>

<td colspan="2"><input type="submit" value="Send"></td>

<td colspan="2"><input type="reset" value="Reset"></td></tr>

</table>

</form>

 

<?php

 

if(isset($_POST['name'])) {

 

$name = $_POST['name'] . "\n";

$email = $_POST['email'] . "\n";

$subject = $_POST['subject'] . "\n";

$messageorig = $_POST['message'] . "\n";

 

$message = "Name: $name " . "\n";

$message .= "Email: $email " . "\n";

$message .= "Message: $messageorig " . "\n";

 

if(mail("[email protected]", $subject, $message, "From: Contact Form")) {

        header("Location: thankyou.html");

} else {

        echo "Mail sending failed";

}

 

}

?>

Link to comment
https://forums.phpfreaks.com/topic/104127-problems-with-an-html-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.