Click to See Complete Forum and Search --> : Need help with formmail.php


shakaku_haru
01-13-2007, 11:52 AM
My form has some problems. When I tried to send a application, it always says that I didn't submit a name. Is there any problems with my coding?

formmail.php coding:
<?php

//variables (change these)

$youremail = "ambracascata@cashette.com";
// your email address

$subject = "Staff Apply";
// the subject of the email

$thankyou = "thanks.php";
// thank you page

// don't change anything else

if($name == ""){
?>
No display name added. Please go back.<br/>
<?php
}elseif($email == ""){
?>
No email added. Please go back.<br/>
<?php
}elseif($position == ""){
?>
No position chosen. Please go back.<br/>
<?php
}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
<?php
}
?>

NightShift58
01-13-2007, 02:15 PM
Try it this way:<?php
//variables (change these)
$youremail = "ambracascata@cashette.com"; // your email address
$subject = "Staff Apply"; // the subject of the email
$thankyou = "thanks.php"; // thank you page
// don't change anything else
//------------------------------------------------------------------------------
// Collect variables from input <form>
$name = $_POST['name'];
$email = $_POST['email'];
$position = $_POST['position'];
$message = $_POST['message'];
//------------------------------------------------------------------------------

if ($name == "") {
print "No display name added. Please go back.<br/>";
} elseif($email == "") {
print "No email added. Please go back.<br/>";
} elseif($position == "") {
print "No position chosen. Please go back.<br/>";
} else {
$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
print "<meta http-equiv='refresh' content='0; url=$thankyou>;
}
?>