Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You simply need to add the checkbox inputs to your form, and retrieve them in your PHP:</p> <p>The HTML:</p> <pre><code>&lt;form method="post" action="process.php"&gt; &lt;input type="email" id="email" name="email" placeholder="Your e-mail" value=" &lt;?php echo ($sr &amp;&amp; !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '' ?&gt;" required="required" /&gt; &lt;input type="text" id="name" name="name" placeholder="Your name" value="&lt;?php echo ($sr &amp;&amp; !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '' ?&gt;" required="required" /&gt; &lt;input type="checkbox" id="CHECKBOX1" name="CHECKBOX1" value="" /&gt;Checkbox 1 </code></pre> <p>(repeat that last input with your desired checkboxes)</p> <p>And the PHP:</p> <pre><code>&lt;?php if( isset($_POST) ){ //form validation vars $formok = true; $errors = array(); //submission data $ipaddress = $_SERVER['REMOTE_ADDR']; $date = date('d/m/Y'); $time = date('H:i:s'); //form data $name = $_POST['name']; $email = $_POST['email']; $telephone = $_POST['telephone']; $enquiry = $_POST['enquiry']; $message = $_POST['message']; &lt;br /&gt; **$checkbox1 = $_POST['CHECKBOX1'];** //validate form data //validate name is not empty if(empty($name)){ $formok = false; $errors[] = "You have not entered a name"; } //validate email address is not empty if(empty($email)){ $formok = false; $errors[] = "You have not entered an email address"; //validate email address is valid }elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){ $formok = false; $errors[] = "You have not entered a valid email address"; } //validate message is not empty if(empty($message)){ $formok = false; $errors[] = "You have not entered a message"; } //validate message is greater than 20 characters elseif(strlen($message) &lt; 20){ $formok = false; $errors[] = "Your message must be greater than 20 characters"; } //send email if all is ok if($formok){ $headers = "From: Goldie Locks online contact form" . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $emailbody = "&lt;p&gt;You have received a new message from the enquiries form on your website.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Name: &lt;/strong&gt; {$name} &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Email Address: &lt;/strong&gt; {$email} &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Message: &lt;/strong&gt; {$message} &lt;/p&gt; **&lt;p&gt;&lt;strong&gt;Checkbox1: &lt;/strong&gt;{$checkbox1}&lt;/p&gt;** &lt;p&gt;This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}&lt;/p&gt;"; mail("MY EMAIL!","New Enquiry",$emailbody,$headers); } //what we need to return back to our form $returndata = array( 'posted_form_data' =&gt; array( 'name' =&gt; $name, 'email' =&gt; $email, 'telephone' =&gt; $telephone, 'enquiry' =&gt; $enquiry, 'message' =&gt; $message ), 'form_ok' =&gt; $formok, 'errors' =&gt; $errors ); //if this is not an ajax request if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest'){ //set session variables session_start(); $_SESSION['cf_returndata'] = $returndata; //redirect back to form header('location: ' . $_SERVER['HTTP_REFERER']); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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