Bri Posted November 14, 2006 Share Posted November 14, 2006 Hi all, I have a php script that simply allows people to email me from my web site. However, it also allows people to add a rating and request a reply.Now this all works fine except unless someone does not tick a rating or request a reply - The email is still sent and all is cool except I just get a blank bit in the resulting email for rating and/or the above reply request.My question is, how can I make it so that if a user does not give me a rating it sends me 'None' and also displays 'Reply NOT requested' if these fields are left blank?This is what I have:[code]$score = $_POST["score"];$mailreply = $_POST["mailreply"];[/code]As you can see, the data is simply taken from the initial form the user fills in.Thanks in advance, Bri Link to comment https://forums.phpfreaks.com/topic/27255-blank-form-fields-php/ Share on other sites More sharing options...
Psycho Posted November 14, 2006 Share Posted November 14, 2006 $score = (isset($_POST["score"]) && $_POST["score"]!="")?$_POST["score"]:"None";$mailreply = (isset($_POST["mailreply"]) && $_POST["mailreply"]!="")?$_POST["mailreply"]:"Reply NOT requested"; Link to comment https://forums.phpfreaks.com/topic/27255-blank-form-fields-php/#findComment-124653 Share on other sites More sharing options...
Bri Posted November 14, 2006 Author Share Posted November 14, 2006 Hi there mjdamato, thanks for your reply - That worked a treat :DCould I bother you once again and ask if the following would work (I have also included the original before editing then as a commented out section):[code]// $name = stripslashes($HTTP_POST_VARS['name']);$name = stripslashes(isset($HTTP_POST_VARS['name']) && $HTTP_POST_VARS["name"]!="")?$HTTP_POST_VARS["name"]:"Anonymous";// $comments = stripslashes($HTTP_POST_VARS['comments']);$comments = stripslashes(isset($HTTP_POST_VARS['comments']) && $HTTP_POST_VARS["comments"]!="")?$HTTP_POST_VARS["comments"]:"Nothing was entered which is kinda pointless but still...";// $formemail = $HTTP_POST_VARS['formemail'];$formemail = (isset($HTTP_POST_VARS['formemail']) && $HTTP_POST_VARS["formemail"]!="")?$HTTP_POST_VARS["formemail"]:"No email entered";$score = (isset($_POST["score"]) && $_POST["score"]!="")?$_POST["score"]:"Not rated";$mailreply = (isset($_POST["mailreply"]) && $_POST["mailreply"]!="")?$_POST["mailreply"]:"Please do not reply to this message";[/code] Link to comment https://forums.phpfreaks.com/topic/27255-blank-form-fields-php/#findComment-124680 Share on other sites More sharing options...
Bri Posted November 14, 2006 Author Share Posted November 14, 2006 Scrap that, I tested the above code and it works a treat :D - Now all I need to do is have some type of proper error checking (server side and non java-script if poss) for the clients message...Anyone? Link to comment https://forums.phpfreaks.com/topic/27255-blank-form-fields-php/#findComment-124708 Share on other sites More sharing options...
Psycho Posted November 14, 2006 Share Posted November 14, 2006 I usggest you start a new thread with what you want the error checking to do exactly. Link to comment https://forums.phpfreaks.com/topic/27255-blank-form-fields-php/#findComment-124712 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.