silversinner Posted July 11, 2008 Share Posted July 11, 2008 Hi. I need a bit of help, Im not sure how to get information from radio boxes into a mysql database. This is the code from partf of the form that used the radio box: <input type="radio" name="plan" style="border: 1px solid #cccccc; background-color: #ffffff;" value="Beginner"/>Beginner </font><font face="verdana" size="2" color="#FF0000"></font><font face="verdana" size="1"><br> <input type="radio" name="plan" style="border: 1px solid #cccccc; background-color: #ffffff;" value="Semi-Pro"/>Semi-Pro </font><font face="verdana" size="2" color="#FF0000"></font><font face="verdana" size="1"><br> <input type="radio" name="plan" style="border: 1px solid #cccccc; background-color: #ffffff;" value="Advanced"/>Advanced And this is the code should put the information into the Mysql Database: <?php $db=mysql_connect("localhost", "unlimite_customers", "*******") or die("Could not connect to localhost."); mysql_select_db("unlimite_customers", $db) or die("Could not find customers."); $querySQL = "insert into customers (name, address, line1, line2, postcode, county, country, phone, contact , paypal, domain, username, password, plan, comments) values ($name, $address, $line1, $line2, $postcode, $county, $country, $phone, $contact , $paypal, $domain, $username, $password, $plan, $comments)"; if(!$querySQL) error_message(sql_error()); ?> the * indicate sensitive info. Im not the most experianced PHP programmer. can anyone see my errors or what im missing out. Regards SS Quote Link to comment https://forums.phpfreaks.com/topic/114316-putting-information-from-radio-boxes-into-mysql-db/ Share on other sites More sharing options...
sasa Posted July 11, 2008 Share Posted July 11, 2008 try <?php $db=mysql_connect("localhost", "unlimite_customers", "*******") or die("Could not connect to localhost."); mysql_select_db("unlimite_customers", $db) or die("Could not find customers."); $querySQL = "insert into customers (name, address, line1, line2, postcode, county, country, phone, contact , paypal, domain, username, password, plan, comments) values ($name, $address, $line1, $line2, $postcode, $county, $country, $phone, $contact , $paypal, $domain, $username, $password, $plan, $comments)"; mysql_query($querySQL) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/114316-putting-information-from-radio-boxes-into-mysql-db/#findComment-587864 Share on other sites More sharing options...
silversinner Posted July 11, 2008 Author Share Posted July 11, 2008 Hi. its still not showing up in the database, im not sure what im doing wrong. heres the whole of the code that handles it: <?php if ($_POST['name'] != "" && $_POST['contact'] && $_POST['paypal'] && $_POST['domain'] && $_POST['username'] && $_POST['password'] ) { $name=$_POST['name']; $address=$_POST['address']; $line1=$_POST['line1']; $line2=$_POST['line2']; $postcode=$_POST['postcode']; $county=$_POST['county']; $country=$_POST['country']; $phone=$_POST['phone']; $contact=$_POST['contact']; $paypal=$_POST['paypal']; $domain=$_POST['domain']; $username=$_POST['username']; $password=$_POST['password']; $plan=$_POST['plan']; $comments=$_POST['comments']; $db=mysql_connect("localhost", "unlimite_customers", "*******") or die("Could not connect to localhost."); mysql_select_db("unlimite_customers", $db) or die("Could not find customers."); $querySQL = "insert into customers (name, address, line1, line2, postcode, county, country, phone, contact , paypal, domain, username, password, plan, comments) values ($name, $address, $line1, $line2, $postcode, $county, $country, $phone, $contact , $paypal, $domain, $username, $password, $plan, $comments)"; mysql_query($querySQL) or die(mysql_error()); ?> I know my form is correct. must be something im doing wrong kind regards SS Quote Link to comment https://forums.phpfreaks.com/topic/114316-putting-information-from-radio-boxes-into-mysql-db/#findComment-587885 Share on other sites More sharing options...
craygo Posted July 11, 2008 Share Posted July 11, 2008 should enclode your table and field names in backticks and your values in single quotes. This saves the headache of using a reserved word be accident. $querySQL = "INSERT INTO `customers` (`name`, `address`, `line1`, `line2`, `postcode`, `county`, `country`, `phone`, `contact`, `paypal`, `domain`, `username`, `password`, `plan`, `comments`) VALUES ('$name', '$address', '$line1', '$line2', '$postcode', '$county', '$country', '$phone', '$contact', '$paypal', '$domain', '$username', '$password', '$plan', '$comments')"; mysql_query($querySQL) or die(mysql_error()); Ray Quote Link to comment https://forums.phpfreaks.com/topic/114316-putting-information-from-radio-boxes-into-mysql-db/#findComment-587889 Share on other sites More sharing options...
silversinner Posted July 11, 2008 Author Share Posted July 11, 2008 Hi, thank its working now. another question, what would i have to do to make the same information going into the MySQL DB also be sent as an email? and then let the user be directed to a payment page, or a signup error? so far ive come up with this: <?php if ($_POST['name'] != "" && $_POST['contact'] && $_POST['paypal'] && $_POST['domain'] && $_POST['username'] && $_POST['password'] ) { $subject="You Have A New Customer Sign-Up!"; $name=$_POST['name']; $address=$_POST['address']; $line1=$_POST['line1']; $line2=$_POST['line2']; $postcode=$_POST['postcode']; $county=$_POST['county']; $country=$_POST['country']; $phone=$_POST['phone']; $contact=$_POST['contact']; $paypal=$_POST['paypal']; $domain=$_POST['domain']; $username=$_POST['username']; $password=$_POST['password']; $plan=$_POST['plan']; $comments=$_POST['comments']; $ip=$_SERVER["REMOTE_ADDR"]; $host = gethostbyaddr($_SERVER['REMOTE_ADDR']); $host = $ip.".".$host; $mon=date(m); $day=date(j); $year=date(y); $hour=date(g); $min=date(i); $sec=date(s); $hour=$hour-2; if($hour<=0) { $hour+=12; } $ts = "$hour:$min:$sec on $day/$mon/$year"; $to="$orders_email"; $body=" Your Name = $name Address = $address Line 1 = $line1 Line 2 = $line2 Post Code = $postcode County = $county Country = $country Phone = $phone Contact E-Mail Address = $contact Paypal E-Mail Address = $paypal Your Domain Name = $domain Requested User Name = $username Requested Password = $password Plan = $plan Additional Comments = $comments Host: $host Time: $ts"; $email = "From: $site_title Sign-up Form <$to>"; mail($to, $subject, $body, $email); $db=mysql_connect("localhost", "unlimite_customers", "******") or die("Could not connect to localhost."); mysql_select_db("unlimite_customers", $db) or die("Could not find customers."); $querySQL = "INSERT INTO `customers` (`name`, `address`, `line1`, `line2`, `postcode`, `county`, `country`, `phone`, `contact`, `paypal`, `domain`, `username`, `password`, `plan`, `comments`) VALUES ('$name', '$address', '$line1', '$line2', '$postcode', '$county', '$country', '$phone', '$contact', '$paypal', '$domain', '$username', '$password', '$plan', '$comments')"; mysql_query($querySQL) or die(mysql_error()); ?> <? include_once "template/header.html"; include_once "body/signup_pay.html"; include_once "template/footer.html"; ?> <?php } else { ?> <? include_once "template/header.html"; include_once "body/signup_error.html"; include_once "template/footer.html"; ?> <? } ?> but it hasnt worked! anyone know why? i cant figure it out. regards SS Quote Link to comment https://forums.phpfreaks.com/topic/114316-putting-information-from-radio-boxes-into-mysql-db/#findComment-587902 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.