perezf Posted September 20, 2006 Share Posted September 20, 2006 i made this code to send an email but i dont want anything sent if the user doesnt fill in required fields[code]<?php$from_header = "From: ".$_POST['from'];$name = $_POST['name'];$to = "[email protected]";$heading = "2fr3sh Email";$contents = $_POST['message'];if(isset($from_header)) && if(isset($contents)) {mail($to, $heading, $contents, $from_header);} else {header("Location: contact.html");}?>[/code] Link to comment https://forums.phpfreaks.com/topic/21405-how-to-stop-an-email-from-being-sent-required-fields/ Share on other sites More sharing options...
Gruzin Posted September 20, 2006 Share Posted September 20, 2006 you can use "empty" or "strlen" functions to avoid sending blank forms. like this:[code]if(empty($name)){ echo "please fill in the name"; exit();}// continue here[/code] Link to comment https://forums.phpfreaks.com/topic/21405-how-to-stop-an-email-from-being-sent-required-fields/#findComment-95326 Share on other sites More sharing options...
perezf Posted September 20, 2006 Author Share Posted September 20, 2006 i want to try and stick to the issets and im getting the following code error[quote]Parse error: parse error, unexpected T_BOOLEAN_AND in /hsphere/local/home/way2fr3s/2fr3sh.com/new/sendmail.php on line 24[/quote][code]<?php$from_header = "From: ".$_POST['from'];$name = $_POST['name'];$to = "[email protected]";$heading = "2fr3sh Email";$contents = $_POST['message'];if(isset($from_header)) && if(isset($contents)) {mail($to, $heading, $contents, $from_header);} else {header("Location: contact.html");}?>[/code] Link to comment https://forums.phpfreaks.com/topic/21405-how-to-stop-an-email-from-being-sent-required-fields/#findComment-95332 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.