Quote:
Originally Posted by monkeymafia
Hi i have a contact form on my website and when the submit button is pressed, i do actually recieve an email but its blank. please help me, i have no idea how to fix it.
Heres the code for my form in html
Code:
<form method ="post" action="send.php">
<p class="areatext">Your name:<br />
<input name="name" size="25">
</p> <br>
<p class="areatext">E-mail address:<br />
<input name="email" size="25">
</p> <br>
<p class="areatext">Your message:<br>
<textarea name="message" rows="4" cols="50"></textarea>
</p> <br>
<p class="areatext">
<input type="submit" value="submit">
<input type="reset" value="Clear">
</p>
</form>
and this is my code for my "send.php" document:
Code:
<?php
// Details
$message="$message";
// Mail of sender
$mail_from="$email";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ='my email address';
$send_contact=mail($to,$message,$header);
// Check, if message sent to your email
// display message "Thank you we have recieved your email, we will get back to you as soon as possible"
if($send_contact){
echo "We've recived your email";
}
else {
echo "ERROR";
}
?>
I have spent a long time trying to get this to work, but php is not my strong point. please hellllp 
|
of course it's blank... check this:
$message="$message";
lol? :P 1. It's equal to its self.. and that's nothing 2.it's set into a string(the var). use this instead for those files:
form
Code:
<form method="POST" action="send.php">
<p class="areatext">Your name:<br />
<input name="name" size="25">
</p> <br>
<p class="areatext">E-mail address:<br />
<input name="email" size="25">
</p> <br>
<p class="areatext">Your message:<br>
<textarea name="message" rows="4" cols="50"></textarea>
</p> <br>
<p class="areatext">
<input type="submit" value="submit">
<input type="reset" value="Clear">
</p>
</form>
send.php
Code:
<?php
// Details
$message = $_POST['message'];
// Mail of sender
$mail_from = $_POST['email'];
// From
$header="from: ".$_POST['name']."<".$mail_from.">";
// Enter your email address
$to ='my email address';
$send_contact = mail($to,$message,$header);
// Check, if message sent to your email
// display message "Thank you we have recieved your email, we will get back to you as soon as possible"
if($send_contact){
echo "We've recived your email";
}
else {
echo "ERROR";
}
?>
try this

Not tested either

But this should work! Good luck!
EDIT: You can also make 1 file of those:
Code:
<?php
if(isset($_POST['submit'])) { //if the user tried to sent the mail(pressed the submit button)
// Details
$message = $_POST['message'];
// Mail of sender
$mail_from = $_POST['email'];
// From
$header="from: ".$_POST['name']."<".$mail_from.">";
// Enter your email address
$to ='my email address';
$send_contact = mail($to,$message,$header);
// Check, if message sent to your email
// display message "Thank you we have recieved your email, we will get back to you as soon as possible"
if($send_contact){
echo "We've recived your email";
}
else {
echo "ERROR";
}
}else{
?>
<form method="POST" action="send.php">
<p class="areatext">Your name:<br />
<input name="name" size="25">
</p> <br>
<p class="areatext">E-mail address:<br />
<input name="email" size="25">
</p> <br>
<p class="areatext">Your message:<br>
<textarea name="message" rows="4" cols="50"></textarea>
</p> <br>
<p class="areatext">
<input type="submit" value="submit" name="submit">
<input type="reset" value="Clear">
</p>
</form>
<?php } ?>