...

View Full Version : Help With Email Script



Rappa
01-21-2008, 06:50 AM
I made a small email script that i cant seem to get to send an email. I was wondering if anyone had the time to look over this code and give me a suggestion.

Form:

<form method="POST" action="remove_me.php">
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td>Name:</td><td><input type="text" name="name" size="25" /></td>
</tr>
<tr>
<td>Badge #:</td><td><input type="text" name="badge" size="25" maxlength="3" /></td>
</tr>
<tr>
<td>Class Name:</td><td><input type="text" name="className" size="25" /></td>
</tr>
<tr>
<td>Class Date:</td><td><input type="text" name="date" size="25" /></td>
</tr>
<tr>
<td>Password:</td><td><input type="password" name="password" size="25" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit Request" />&nbsp;<input type="reset" name="reset" value="Reset" /></td>
</tr>
</table>
</form>

remove_me.php:

<?php
$name = $_POST["name"];
$badge = $_POST["badge"];
$className = $_POST["className"];
$date = $_POST["date"];
$password = $_POST["password"];
$pw = "password";
$to = "rappa819@gmail.com";
$subject = "Class Remove Request";
$message = "$name\n$badge\n$className\n$date";

if (empty($name) || empty($badge) || empty($className) || empty($date) || empty($password)) {
echo "Please Fill In All The Fields. <a href=\"removeme.php\">Back</a>";
}
else if ($password != $pw) {
echo "Invalid Password. <a href=\"removeme.php\">Back</a>";
}
else if (!empty($name) && !empty($badge) && !empty($className) && !empty($date) && $password == $pw) {

if (mail($to, $subject, $message)) {
echo "Request Successfully Sent";
}
else {
echo "Failed to send Removal Request";
}
}
?>

At least i get the "Failed to..." echo. But i dont know why its not sending. Im not that great with php as you see.

Thanks in advance.

student101
01-21-2008, 09:59 AM
Quick send mail scripts.

http://www.w3schools.com/php/php_mail.asp

http://www.php-scripts.com/php_diary/122899.php3

Hope they help you understand what you need done, better.

Cheers

Mwnciau
01-21-2008, 11:37 AM
Put error_reporting ( E_ALL ) at the top of your script and see if you get any warnings or notices.

Are you sure the SMTP is set up in your php.ini?

Jon W
01-21-2008, 06:33 PM
Try putting:




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

// then do this...

}



Hope that helps. Best regrades,

Jon W



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum