Jump to content


Photo

How to stop an email from being sent "Required Fields"


  • Please log in to reply
2 replies to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 20 September 2006 - 02:03 PM

i made this code to send an email but i dont want anything sent if the user doesnt fill in required fields


<?php
$from_header = "From: ".$_POST['from'];
$name = $_POST['name'];
$to = "2fr3sh@gmail.com";
$heading = "2fr3sh Email";
$contents = $_POST['message'];

if(isset($from_header)) && if(isset($contents)) {
mail($to, $heading, $contents, $from_header);
} else {header("Location: contact.html");}
?>


#2 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 September 2006 - 02:05 PM

you can use "empty" or "strlen" functions to avoid sending blank forms. like this:

if(empty($name)){
  echo "please fill in the name";
  exit();
}
// continue here

I don't need your script, I'll try to write it myself

#3 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 20 September 2006 - 02:09 PM

i want to try and stick to the issets and im getting the following code error

Parse error: parse error, unexpected T_BOOLEAN_AND in /hsphere/local/home/way2fr3s/2fr3sh.com/new/sendmail.php on line 24

<?php
$from_header = "From: ".$_POST['from'];
$name = $_POST['name'];
$to = "2fr3sh@gmail.com";
$heading = "2fr3sh Email";
$contents = $_POST['message'];

if(isset($from_header)) && if(isset($contents)) {
mail($to, $heading, $contents, $from_header);
} else {header("Location: contact.html");}
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users