Forum Moderators: coopster
I can send mail from my website except when I add information from a form.
The second I add user enter variables somethig goes wrong .
Perhaps you guys can help me
Here is the form :
<form name="input" action="email.php" method="post" enctype="text/plain">
Type your first name:
<br>
<input type="text" name="FirstName" value="Name" size="20" style="font-
family:verdana;font-size:80%;color:#000000">
<br>Type your last name:
<br>
<input type="text" name="LastName" value="Last Name" size="20"
style="font-family:verdana;font-size:80%;color:#000000">
<br>Email address
<br>
<input type="text" name="Email" value="email@email.com" size="20"
style="font-family:verdana;font-
size:80%;color:#000000" >
<br>Title
<br>
<input type="text" name="Title" value="Title" size="20" style="font-
family:verdana;font-size:80%;color:#000000" >
<br>
<textarea rows="10" cols="30" name="Message" style="font-family:verdana;font-size:80%;color:#000000" >Enter Message here </textarea>
<br>
<br>
<input type="submit" value="Submit">
<input type="submit" value="Reset">
</form>
and here is the adjoining php script :
<?php
$subject = "Test Message";
$name = $_POST["FirstName"];
$surname = $_POST["LastName"] ;
$email2 = $_POST["Email"] ;
$from = "FROM: $name $surname <$email2>";
//$from = "FROM: test <test@test.com>";
$email = "me@me.com";
//estmessage body
$body = $_POST["Message"] ;
if (!mail($email, $subject, $body, $from)) { echo "Error Sending Email!"; }
else
{ echo "Mail sent!"; }
///////////////////////////
// Finish sending emails //
//////////////////////////
?>
What I definately know is wrong is the $from , I have been messing around with a couple of variables . but its not even sending the body.
<form method="POST" action="email.php">
Name:
<br>
<input type="text" name="name" size="19"><br>
<br>
Email:
<br>
<input type="text" name="email" size="19"><br>
<br>
Message:
<br>
<textarea rows="9" name="message" cols="30"></textarea>
<br>
<br>
<input type="submit" value="Submit" name="submit">
</form>
<?php
if(isset($_POST['submit'])) {
$to = "blah@gmail.com";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>
And all i get is blarg does anyone know what the problem with the if(isset($_POST['submit'])) or the posting ?
Regards
Malcolm
So i have the following questions :
1. Do you need any special settings to post
Regards
Malcolm
Little info:
in case you have problems with submitted data try this trick...
echo "<pre>":
print_r($_POST);
echo "</pre>";
You will see all submitted data to your page via POST method.
This works also for GET, SESSION, COOKIE and many others.
Btw, what was the problem?