Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Checkbox - return 'Yes' instead of 1 how?
    primarykey
    data
    text
    <p>I have a simple contact form with a checkbox, once valid and submitted I echo out the results of the form. I would like the checkbox item to return YES if checked and NO if blank.</p> <p>Here is my snippet:</p> <pre><code> $subject = "Website Contact Form Enquiry"; //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['contactname']) == '') { $hasError = true; } else { $name = trim($_POST['contactname']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) == '') { $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } if(isset($_POST['tour']) &amp;&amp; $_POST['tour'] == 'yes') { $tour = true; } else { $tour = false; } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'info@bgv.co.za'; //Put your own email address here $body = "Name: $name \n\nEmail: $email \n\nComments:\n $comments"; $headers = 'From: My Site &lt;'.$emailTo.'&gt;' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } </code></pre> <p>Heres the echo</p> <pre><code> &lt;?php if(isset($emailSent) &amp;&amp; $emailSent == true) { //If email is sent ?&gt; &lt;div id="sadhu"&gt; &lt;p class="general_site"&gt;Name:&lt;/p&gt;&lt;p class="general_siter"&gt;&lt;strong&gt;&lt;?php echo $name;?&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p class="general_site"&gt;Email:&lt;/p&gt;&lt;p class="general_siter"&gt;&lt;strong&gt;&lt;?php echo $email;?&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p class="general_site"&gt;Message:&lt;/p&gt;&lt;p class="general_siter"&gt;&lt;strong&gt;&lt;?php echo $comments;?&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p class="general_site"&gt;Tour:&lt;/p&gt;&lt;p class="general_siter"&gt;&lt;strong&gt;&lt;?php echo $tour;?&gt;&lt;/strong&gt;&lt;/p&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload