manual mail firings

If someone could help me with my script it would be greatly appreciated as i am not an expert.
I’m using a standalone mail script to work as a post method on a form, whilst the form is impossible to submit blank due to my javascript workarounds, theres nothing to stop someone firing it in the url bar if they look through the html and find it, why someone would do that i don’t know, unless it is a problem with the server that it is on (not mine)
here is the script at

<?php $EmailFrom = Trim(stripslashes($_POST['Email'])); $Subject = Trim(stripslashes($_POST['Subject'])); $MESSAGE_BODY = "Name: " .($_POST['Name'])." "; $MESSAGE_BODY .= "\n Phone Number: " .($_POST['Phone'])." "; $MESSAGE_BODY .= "\n Message: \n\n".($_POST["Message"])." "; $success = mail("email", $Subject, $MESSAGE_BODY, "From: $Email"); if ($success){ print ""; } ?>

Every so often i receive a blank message, no address, subject or body. Any ideas of how to prevent this?

Hi there,

I tend to use the following layout:
$errors = array();
$name = (isset($_POST[‘name’])) ? trim(strip_tags($_POST[‘name’])) : “”;
$message = (isset($_POST[‘message’])) ? trim(strip_tags($_POST[‘message’])) : “”;

if(strlen($name) < 3)
    $errors[] = "The name field must contain 3 or more characters.";
if(strlen($name) < 10)
    $errors[] = "Please enter a message of at least 10 characters in length.";

    echo "<p>E-Mail could not be sent due to the following errors:</p>";
    echo "<ul><li>".implode("</li><li>",$errors)."</li></ul>";


Is that the sort of thing you’re looking for?

Sponsor our Newsletter | Privacy Policy | Terms of Service