Jump to content

Blank form fields & php


Bri

Recommended Posts

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

Hi there mjdamato, thanks for your reply - That worked a treat :D

Could 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.