Validating checkboxes in php

validating checkboxes in php-51
The page was working fine before I added the radio button and the "Agree" was being added to the database.

Tags: Sex chat with girls that wanna fuckLive sex chate arban girlsdatingbattle inschrijving dating site 2016james kyson lee married datingbaltic dating comFree adult mobile chats no sign upadult sex dating in smithville mississippiwho is jade olivia dating

if ($_SERVER[' REQUEST_METHOD'] == ' POST') { if (isset($_POST[' Agree'])) else // Check for a first name: if (preg_match ('/^[A-Z \'.-]$/i', stripslashes($_POST['first_name']))) else // Check for a middle name: if (preg_match ('/^[A-Z \'.-]$/i', stripslashes($_POST['mid_initial']))) else // Check for a last name: if (preg_match ('/^[A-Z \'.-]$/i', stripslashes($_POST['last_name']))) else // Check for a username: if (preg_match ('/^[A-Z0-9 \'.-]$/i', stripslashes($_POST['username']))) else // Check for an email address: if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) else // Check for a password and match against the confirmed password: if (preg_match ('/^(\w*(? You have some non-standard practices in your code such as including styling within the html, using a capital letter in your your variables e.g.

' Agree' and not using ascii codes for special chars in your html e.g. I hope you don't mind my pointing these out but its good idea to use good practices.

As such, with radio buttons and checkboxes, you have to first check for the existence of a value before you can even start parsing the value. You will very easily be able to see exactly what values are (or aren't) being sent to the $_POST array.

Without looking at your code, I have a feeling that this is the problem. With that code in place, try both selecting and not selecting the checkbox, and see how it affects your $_POST array.

Also, please put your code samples within code tags from now on. Similarly, once you have resolved the problem with the $_POST array and you are getting the expected value, next add the following code right before the if (empty($reg_errors)) elseif ($type == 'checkbox') else Marie, it's hard to speculate why "on" is being put into your DB without seeing more code.

It's the same advice as before, but I highly recommend echoing lots and lots of values out to the screen each step of the way. If the error doesn't seem to be in the PHP, then it's always possible that the way you have structured your DB is causing the problem.As a side, you shouldn't give your a element the same name and ID as the input element.That could cause some issues in some browsers, especially if you are using Javascript. Also, what are you using an empty a element for (which doesn't have an href attribute, by the way)?To make it work as expected the javascript code in your validate_form function will need some changes. In line 3 of modified function above we use powerful eval function to evaluate the string passed to it.The eval function accepts any valid piece of javascript code and returns output value.Basically I was trying to follow along with the code that I already have for the other form elements.So I haven't tried the futher suggestions yet, in case the solution would be very simple.Marie, I'm not sure what your create_form_input function does (and I'm confused about some of your HTML), but the following is a very simple works-out-of-the-box demonstration of how to handle radio button logic.The first thing you should do is test whether any radio buttons are selected or not with the isset function.Obviously I only want anything to go to the database when everything is filled out.I would rather not use Javascript and don't understand why php would work with the rest of the fields but not with a checkbox or radio button. =\w*[A-Z])\w*)$/', $_POST['pass1']) ) else if (empty($reg_errors)) { // If everything's OK...


Comments Validating checkboxes in php

The Latest from ©