Jump to content

Putting information from Radio boxes into MySQL DB


silversinner

Recommended Posts

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

 

 

Link to comment
Share on other sites

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()); 
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.