ben3001 Posted December 10, 2006 Share Posted December 10, 2006 (edited) I have this which is a basic form. on it i would like to add a check box saying, do you want more information if they tick it in the email i get i'll see yes. i've been trying to work it out and i cant find the solution any ideas are apprecited, thanks ben <!-- CONTACT FORM --> <?php $sub = isset( $_GET[ 'sub']) ? $_GET[ 'sub'] : false; if( isset( $_POST[ 'action'])) { $sub = strlen( $_POST[ 'subject']) > 0 ? $_POST[ 'subject'] : false; $custname = strlen( $_POST[ 'custname']) > 0 ? $_POST[ 'custname'] : false; if( !eregi( "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$", $_POST[ 'custemail'])) $custemail = false; else $custemail = $_POST[ 'custemail']; $custno = strlen( $_POST[ 'custno']) > 0 ? $_POST[ 'custno'] : false; $enquiry = strlen( $_POST[ 'custenq']) > 0 && strlen( $_POST[ 'custenq']) < 200 ? $_POST[ 'custenq'] : false; /* Validate all fields as we want to be able to contact the customer */ if( $sub && $custname && $custemail && $custno && $enquiry) { // We want to process this request and try and send it $header = 'From:' . $custemail . "\r\n" . // This allows us to reply to the message directly 'Reply-To: ' . $custemail . "\r\n" . 'X-Mailer: PHP/' . phpversion( ); $message = " Customer Name: " . $custname . "\n" . " Enquiry: " . $enquiry. "\n\n" . $custemail . " Phone no: " . $custno; if( mail( "email", "Product Enquiry:" . $sub, $message, $header)) { // Mail the customer a confirmation mail( $custemail, "D-View Auto Reply ", "Dear $custname," . "\r\n" . "Thank-you for contacting , regarding the product: $sub , your enquiry has been sent and you should be " . "contacted shortly" . "\r\n" . "We attempt to respond to all e-mails within 24 hours, but during busy times this make take " . "\r\n" . "longer." . "\r\n" . "Once again, thank-you for your enquiry " , "From: no-reply@.com" . "\r\n" . "Reply-To: no-reply@.com" . "\r\n" . "X-Mailer: PHP/" . phpversion( )); $success = true; }else{ $success = false; } } else $errors = true; } if( isset( $errors ) && $errors == true) { ?> <div style="color: #ff5050">There were errors in your submission, all fields are required. </div> <?php } if( isset( $success)) { if( $success) { ?> <div style="color: #333333;"><strong>Your enquiry has been sent, you should receive an e-mail confirmation shortly.</strong></div> <?php } else { ?> <div style="color: #ff5050;">There was an error with your enquiry please try again later. </div> <?php } } ?> <form action="product.php" method="post"> <div class="fmTitle">Product ID</div> <div class="fmField"> <input type="text" name="subject" value="<?= $sub; ?>" size="32" maxlength="32" /> <span class="style6">*</span><br /> <br /> </div> <div class="fmTitle">Name</div> <div class="fmField"> <input type="text" name="custname" value="<?= $custname; ?>" size="25" maxlength="25" /> <span class="style6">*</span><br /> <br /> </div> <div class="fmTitle">Email</div> <div class="fmField"> <input type="text" name="custemail" value="<?= $custemail; ?>" size="35" maxlength="60" /> <span class="style6">*</span><br /> <br /> </div> <div class="fmTitle">Phone</div> <div class="fmField"> <input type="text" name="custno" value="<?= $custno; ?>" size="20" maxlength="13" /> <span class="style6">*</span><br /> <br /> </div> <div class="fmTitle">Enquiry</div> <div class="fmField"> <textarea name="custenq" cols="60" rows="5" onKeyDown="limitText(this.form.custenq,this.form.countdown,200);" onKeyUp="limitText(this.form.custenq,this.form.countdown,200);"><?= $custenq; ?></textarea> <span class="style6">*</span><br><font size="1"> </font><div class="style7">.</div><font size="1">(Maximum characters: 200) <span class="style6">*Required </span><br />You have <input name="countdown" type="text" value="200" size="3" readonly="readonly" /> characters left.</font> <br /> <br /> </div> <div class="fmTitle"> </div> <div class="fmField"> <input type="hidden" name="action" value="productenq" /> <input type="submit" value="Submit" name="submit" /> <input type="reset" value="Reset" name="reset" /> </div> </form> <!-- END CONTACT FORM --> Edited September 9, 2010 by ben3001 Link to comment Share on other sites More sharing options...
justsomeguy Posted December 11, 2006 Share Posted December 11, 2006 Give your checkbox a name and a value:<input type="checkbox" name="cb_test" value="yes">And then you can check it in PHP:if ($_POST['cb_test'] == "yes")//the checkbox was clicked Link to comment Share on other sites More sharing options...
ben3001 Posted December 12, 2006 Author Share Posted December 12, 2006 oops lol i kinda forgot about this topic i found out what i was doing wrong, i forgot to define the valuesorry about that i should of said thanks anyways Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now