Check Box value not being passed on to database

malaheem

New Member
I am using an MySQL table with the following structure:\[code\]`login` ( `loginid` int(11) unsigned NOT NULL auto_increment, `username` varchar(30) NOT NULL, `password` varchar(50) NOT NULL, `email` varchar(255) NOT NULL, `actcode` varchar(45) NOT NULL, `disabled` tinyint(1) NOT NULL default '0', `activated` tinyint(1) NOT NULL default '0', `created` timestamp NOT NULL default CURRENT_TIMESTAMP, `points` bigint(9) NOT NULL, `website` varchar(1000) NOT NULL, `location` varchar(1000) NOT NULL, `age` varchar(1000) NOT NULL, `gender` varchar(1000) NOT NULL, `subcheckr` tinyint(1) NOT NULL, PRIMARY KEY (`loginid`))\[/code\]I have several fields that the user can fill out while registering. They all work fine (the information is transmitted to the database). I also have a checkbox for a user to select while registering. However, when a user selects the check box, the value "1" is not being transmitted to the database. The checkbox has the name of "subcheckr" in both the code below and the database.Any idea why the checkbox is not working?Thanks in advance,JohnWhen a user registers, I am using the following code:\[code\]function show_registration_form(){ echo '<form action="http://www...com/.../register.php" method="post"> <div class="register"><label for="username">Select Username:</label></div> <div class="registerform"><input name="username" type="text" id="username" maxlength="30"></div> <div class="passwordregister"><label for="password">Select Password:</label></div> <div class="passwordregisterform"><input name="password" type="password" id="password" maxlength="15"></div> <div class="passwordregister2"><label for="password2">Re-type password:</label></div> <div class="passwordregister2form"><input name="password2" type="password" id="password2" maxlength="15"></div> <div class="emailregister"><label for="email">Your Email (required):</label></div> <div class="emailregisterform"><input name="email" type="text" id="email" maxlength="255"></div> <div class="websiteregister"><label for="website">Your Website (optional):</label></div> <div class="websiteregisterform"><input name="website" type="text" id="website" maxlength="255"></div> <div class="locationregister"><label for="website">Your Location (optional):</label></div> <div class="locationregisterform"><input name="location" type="text" id="location" maxlength="255"></div> <div class="ageregister"><label for="website">Your Age (optional):</label></div> <div class="ageregisterform"><input name="age" type="text" id="age" maxlength="255"></div> <div class="genderregister"><label for="website">Your Gender (optional):</label></div> <div class="genderregisterform"><input name="gender" type="text" id="gender" maxlength="255"></div> <div class="subcheckr"><INPUT TYPE=CHECKBOX NAME="subcheckr">Click here to receive updates via email (optional).<P></div> <p class="registerbutton"> <input name="register" type="submit" value="http://stackoverflow.com/questions/3867686/Register"> </p> </form>';}\[/code\]The following code is on the page register.php:\[code\]if (isset($_POST['register'])){ if (registerNewUser($_POST['username'], $_POST['password'], $_POST['password2'], $_POST['email'], $_POST['website'], $_POST['location'], $_POST['age'], $_POST['gender'], $_POST['subcheckr'])){ echo '<div class="submittitle">Thank you for registering, an email has been sent to your inbox, Please activate your account.</div>'; }else { echo '<div class="submittitler">There was a problem with your registration. Perhaps the username or email you picked was already in use. Please try again.</div>'; show_registration_form(); }} else {// has not pressed the register button show_registration_form(); }\[/code\]Here is the new registration function:\[code\]function registerNewUser($username, $password, $password2, $email, $website, $location, $age, $gender, $subcheckr){ global $seed; if (!valid_username($username) || !valid_password($password) || !valid_email($email) || $password != $password2 || user_exists($username) || email_exists($email)) { return false; } $code = generate_code(20); $sql = sprintf("insert into login (username,password,email,actcode, website, location, age, gender, subcheckr) value ('%s','%s','%s','%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($username), mysql_real_escape_string(sha1($password . $seed)) , mysql_real_escape_string($email), mysql_real_escape_string($code), mysql_real_escape_string($website), mysql_real_escape_string($location), mysql_real_escape_string($age), mysql_real_escape_string($gender), mysql_real_escape_string($subcheckr)); if (mysql_query($sql)) { $id = mysql_insert_id(); if (sendActivationEmail($username, $password, $id, $email, $code)) { return true; } else { return false; } } else { return false; } return false;}\[/code\]
 
Back
Top