Why isn't my form submitting data into my database? - php

Alright so I have a form and i'm trying to get it to submit data into my database but it's not working... i'm not sure if it's my form that is causing the issue or if it's a problem with connecting to the database?
My table names are correct, value fields, log-in info... but whenever I hit submit it is not inserting any data.
Could it be my form that is having the issue?? Would you guys mind taking a look?
<form action="form.php" method="POST">
<div class="row">
<div class="large-4 columns">
<span id="spryfirstname">
<input name="firstname" type="text" class="text" placeholder="First Name"/>
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
<div class="large-4 columns">
<span id="sprylastname">
<input name="lastname" type="text" class="text" placeholder="Last Name"/>
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
<div class="large-4 columns">
<div class="row collapse">
<div class="small-9 columns"><span id="spryemail">
<input name="email" type="text" placeholder="email#example.com"/>
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
</div>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>Check all Products that you're interested in</label>
<div>
<input name="products[]" type="checkbox" value="all">
ALL PRODUCTS/SERVICES
<input name="products[]" type="checkbox" vallue="trade">Trade-in
<input name="products[]" type="checkbox" value="layaway">Layaway products
<input name="products[]" type="checkbox" value="theatre">Home Theatre Systems
<input name="products[]" type="checkbox" value="TV">HD TVs
<input name="products[]" type="checkbox" value="Games">Video Game Consoles</label> <br>
<input name="products[]" type="checkbox" value="laptops"> Laptops</label>
<input name="products[]" type="checkbox" value="monitors"> Monitors</label>
<input name="products[]" type="checkbox" value="phones"> Phones</label>
<input name="products[]" type="checkbox" value="cameras"> Cameras</label>
<input name="products[]" type="checkbox" value="acoustic"> Acoustic Guitars</label>
<input name="products[]" type="checkbox" value="electric"> Electric Guitars</label>
<input name="products[]" type="checkbox" value="drums"> Drums</label>
<input name="products[]" type="checkbox" value="wind"> Wind Instruments</label> <br>
<input name="products[]" type="checkbox" value="pianos"> Pianos</label>
<input name="products[]" type="checkbox" value="violins"> Violins</label>
<input name="products[]" type="checkbox" value="diamonds"> Diamonds
<input name="products[]" type="checkbox" value="neck"> Necklaces
<input name="products[]" type="checkbox" value="rings"> Rings
<input name="products[]" type="checkbox" value="ear"> Ear Rings</label>
<input name="products[]" type="checkbox" value="gold"> Gold Jewelry
<input name="products[]" type="checkbox" value="silver"> Silver Jewelry
<hr>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>How often would you like to have product updates? <select>
<option value="daily" name"Updates">Daily</option>
<option value="weekly" name"Updates">Weekly</option>
<option value="monthly" name"Updates">Monthly</option>
</select>
</label>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>Tell us a little about yourself <textarea placeholder="Type here">
</textarea>
</label>
</div>
</div>
<div class="row">
<input class="button small large-3" type="submit" name"submit" />
</div>
</form>
Here's my connecting to the database part:
<?php
if (isset($_POST['submit'])){
$con = mysql_connect("localhost","dxh6110","******");
if(!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("dxh6110",$con);
$sql = "INSERT INTO Signup (Firstname,Lastname,Email) VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[email]')";
mysql_query($sql,$con);
mysql_close($con);
}
?>
Also, if I want to enter data from the checkboxes and drop down how would I go about doing that? Will it be the same as textfields?

This answer for your originally posted code before your edit and without marking it as an edit.
This is the reason:
You have no equal sign in name"submit" for your submit button.
Change it to name="submit" which your code's execution is based on your conditional statement:
if (isset($_POST['submit']))
It took me a while to spot that one after staring at your code, wondering "why" it wasn't working.
The rest of your code does check out, however I must also state that your present code is open to SQL injection. Use prepared statements, or PDO with prepared statements, they're much safer.
As for your checkboxes, you can base yourself on the following:
$checkbox = $_POST['products'];
for($i=0;$i <sizeof($checkbox);$i++) {
$query="INSERT INTO your_table (col) VALUES('".$checkbox[$i]."')";
mysql_query($query,$con) or die(mysql_error());
}
For some added protection:
$firstname= stripslashes($_POST['firstname']);
$lastname= stripslashes($_POST['lastname']);
$email = stripslashes($_POST['email']);
$firstname= mysql_real_escape_string($_POST['firstname']);
$lastname= mysql_real_escape_string($_POST['lastname']);
$email = mysql_real_escape_string($_POST['email']);
$sql = "INSERT INTO Signup (Firstname,Lastname,Email)
VALUES('".$firstname."','".$lastname."','".$email."')";
or mysqli_ method:
<?php
$con = mysqli_connect("myhost","myuser","mypassw","mybd")
or die("Error " . mysqli_error($con));
$firstname = stripslashes($_POST['firstname']);
$lastname = stripslashes($_POST['lastname']);
$email = stripslashes($_POST['email']);
$firstname = mysqli_real_escape_string($con,$_POST['firstname']);
$lastname = mysqli_real_escape_string($con,$_POST['lastname']);
$email = mysqli_real_escape_string($con,$_POST['email']);
$sql = "INSERT INTO Signup (Firstname,Lastname,Email)
VALUES('".$firstname."','".$lastname."','".$email."')";
mysqli_query($con,$sql);
mysqli_close($con);

Related

how to use checkbox and input type number together in php

I am creating a meeting room booking application using php. In that, when a person book a room there have an option to book tea or snacks and specify the number of items they need. For that, I use checkboxes to select items and input type number to specify the number of items.i.e, if tea selected you have to specify the no. of tea in the input field. My problem is that I can't store or display the checkbox value and associated number together.my code is
<form class="form-horizontal" method="post" id="bookroom" action="bookedreview.php">
<h4>Food & Beverages</h4>
<div class="checkbox">
<input type="checkbox" value="tea" name="food[]"><label>Tea</label>
<input type="number" name="foodnum[]">
</div>
<div class="checkbox">
<input type="checkbox" value="coffee" name="food[]"><label>Coffee</label>
<input type="number" name="foodnum[]">
</div>
<div class="checkbox">
<input type="checkbox" value="snacks" name="food[]"><label>Snacks</label>
<input type="number" name="foodnum[]">
</div>
<div class="checkbox">
<input type="checkbox" value="water" name="food[]"><label>Water</label>
<input type="number" name="foodnum[]">
</div>
<div class="checkbox">
<input type="checkbox" value="nuts" name="food[]"><label>Nuts</label>
<input type="number" name="foodnum[]">
</div>
<div class="checkbox">
<input type="checkbox" value="breakfast" name="food[]"><label>Breakfast</label>
<input type="number" name="foodnum[]">
</div>
<div class="checkbox">
<input type="checkbox" value="lunch" name="food[]"><label>Lunch</label>
<input type="number" name="foodnum[]">
</div>
<div class="checkbox">
<input type="checkbox" value="dinner" name="food[]"><label>Dinner</label>
<input type="number" name="foodnum[]">
</div>
<input type="submit" name="submit" value="value">
</form>
if (isset($_POST['submit']))
{
$foodnum=$_POST['foodnum'];
$food=$_POST['food'];
//$food=implode(',',$_POST['food']);
foreach($foodnum as $index =>$value){
$fud=$value;
$num=$foodnum['index'];
}
}
but when I display the variable I couldn't get the result. Can anyone help me how could store the checked items and the associated quantity together.
You can get with passing food name in textbox name array
<form class="form-horizontal" method="post" id="bookroom" action="">
<h4>Food & Beverages</h4>
<div class="checkbox">
<input type="checkbox" value="tea" name="food[]"><label>Tea</label>
<input type="number" name="foodnum[tea]">
</div>
<div class="checkbox">
<input type="checkbox" value="coffee" name="food[]"><label>Coffee</label>
<input type="number" name="foodnum[coffee]">
</div>
<div class="checkbox">
<input type="checkbox" value="snacks" name="food[]"><label>Snacks</label>
<input type="number" name="foodnum[snacks]">
</div>
<div class="checkbox">
<input type="checkbox" value="water" name="food[]"><label>Water</label>
<input type="number" name="foodnum[water]">
</div>
<div class="checkbox">
<input type="checkbox" value="nuts" name="food[]"><label>Nuts</label>
<input type="number" name="foodnum[nuts]">
</div>
<div class="checkbox">
<input type="checkbox" value="breakfast" name="food[]"><label>Breakfast</label>
<input type="number" name="foodnum[breakfast]">
</div>
<div class="checkbox">
<input type="checkbox" value="lunch" name="food[]"><label>Lunch</label>
<input type="number" name="foodnum[lunch]">
</div>
<div class="checkbox">
<input type="checkbox" value="dinner" name="food[]"><label>Dinner</label>
<input type="number" name="foodnum[dinner]">
</div>
<input type="submit" name="submit" value="value">
</form>
<?php
if (isset($_POST['submit']))
{
$foodnum=$_POST['foodnum'];
$food=$_POST['food'];
echo "<table border='1' style='width:100%'><tr><th>Food Name</th><th>Count</th></tr>";
// output data of each row
foreach($food as $foo)
{
echo "<tr><td>".$foo."</td><td>".$foodnum[$foo]."</td></tr>";
}
echo "</table>";
}
?>
For Insert
foreach($food as $foo)
{
$fieldVal1=$foo;
$fieldVal1=$foodnum[$foo];
$query ="INSERT INTO foodcounts( foodsname, cnt) VALUES ('".$fieldVal1."','".$fieldVal2."' )";
mysqli_query($conn, $query);
}

CheckBox html-php-mysql

my problem sir/ma'am is in checkbox html-php-mysql, if box is check then the value that will save in MYSql is "COMPLETED" and if it is not check the box then it will also save the value of "NOT COMPLETED" in mysql, but in my case it will save still NOT COMPLETED even it is check
<h1><span class="label label-primary left">Requirements</span></h1><br><br>
<div class="checkbox ">
<label><input type="checkbox" name="Card" value="Complete">
<input type="hidden" name="Card" value="Not Complete">High School Card (Form 138)</label>
</div> <div class="checkbox b">
<label><input type="checkbox" name="MoralCertificate" value="Complete">
<input type="hidden" name="MoralCertificate" value="Not Complete">
Good Moral Certificate</label>
</div> <div class="checkbox bb">
<label><input type="checkbox" name="BirthCertificate" value="Complete">
<input type="hidden" name="BirthCertificate" value="Not Complete">
NSO Birth Certificate</label>
</div> <div class="checkbox bbb">
<label><input type="checkbox" name="IDPicture" value="Complete">
<input type="hidden" name="IDPicture" value="Not Complete">
2x2 Formal ID Picture</label>
</div> <div class="checkbox bbbb">
<label><input type="checkbox" name="HonorStudents" value="Complete">
<input type="hidden" name="HonorStudents" value="Not Complete">
Certification for Honor Students</label>
</div> <div class="checkbox bbbbb">
<label><input type="checkbox" name="Form137" value="Complete">
<input type="hidden" name="Form137" value="Not Complete">
Form 137</label>
</div>
$Elementary = $_POST['Elementary'];
$YearGraduated = $_POST['YearGraduated'];
$AwardsReceived = $_POST['AwardsReceived'];
$Year = $_POST['Year'];
$Place = $_POST['Place'];
$status = $_POST['Card'];
$MoralCertificate = $_POST['MoralCertificate'];
$BirthCertificate = $_POST['BirthCertificate'];
$IDPicture = $_POST['IDPicture'];
$HonorStudents = $_POST['HonorStudents'];
$Form137 = $_POST['Form137'];
mysqli_query($con,"INSERT INTO educationalbackground (Elementary, YearGraduated, AwardsReceived, Year, Place, Card, MoralCertificate, BirthCertificate, IDPicture, HonorStudents, Form137 )
VALUES ('$Elementary','$YearGraduated', '$AwardsReceived', '$Year', '$Place', '$status', '$MoralCertificate', '$BirthCertificate', '$IDPicture', '$HonorStudents', '$Form137')");
header("Location: ThirdForm.php");
mysqli_close($con);
enter code hereenter image description hereenter image description here
You should simplify this using one checkbox per item.
<div class="checkbox">
<label>
<input type="checkbox" name="Card" value=1>
High School Card (Form 138)
</label>
</div>
Then in php check the results like so....
if(isset($_POST['Card'])){
// Card Completed
}else{
// Card Not Completed
}

adding dropdown data into my DB

Alright so knocking some issues out one by one, now I am trying to get my dropdown menu data to submit. I don't know where to start with this one though.
here's my form.. anything wrong here? :
<form action="form.php" method="POST">
<div class="row">
<div class="large-4 columns">
<span id="spryfirstname">
<input name="firstname" type="text" placeholder="First Name"/>
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
<div class="large-4 columns">
<span id="sprylastname">
<input name="lastname" type="text" placeholder="Last Name"/>
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
<div class="large-4 columns">
<div class="row collapse">
<div class="small-9 columns"><span id="spryemail">
<input name="email" type="text" placeholder="email#example.com"/>
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
</div>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>Check all Products that you're interested in</label>
<input name="products[]" type="checkbox" value="all">
ALL PRODUCTS/SERVICES
<input name="products[]" type="checkbox" vallue="trade">Trade-in
<input name="products[]" type="checkbox" value="layaway">Layaway products
<input name="products[]" type="checkbox" value="theatre">Home Theatre Systems
<input name="products[]" type="checkbox" value="TV">HD TVs
<input name="products[]" type="checkbox" value="Games">Video Game Consoles<br>
<input name="products[]" type="checkbox" value="laptops"> Laptops
<input name="products[]" type="checkbox" value="monitors"> Monitors
<input name="products[]" type="checkbox" value="phones"> Phones
<input name="products[]" type="checkbox" value="cameras"> Cameras
<input name="products[]" type="checkbox" value="acoustic"> Acoustic Guitars
<input name="products[]" type="checkbox" value="electric"> Electric Guitars
<input name="products[]" type="checkbox" value="drums"> Drums
<input name="products[]" type="checkbox" value="wind"> Wind Instruments <br>
<input name="products[]" type="checkbox" value="pianos"> Pianos
<input name="products[]" type="checkbox" value="violins"> Violins
<input name="products[]" type="checkbox" value="diamonds"> Diamonds
<input name="products[]" type="checkbox" value="neck"> Necklaces
<input name="products[]" type="checkbox" value="rings"> Rings
<input name="products[]" type="checkbox" value="ear"> Ear Rings
<input name="products[]" type="checkbox" value="gold"> Gold Jewelry
<input name="products[]" type="checkbox" value="silver"> Silver Jewelry
<hr>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>How often would you like to have product updates? <select>
<option value="daily" name="Updates">Daily</option>
<option value="weekly" name="Updates">Weekly</option>
<option value="monthly" name="Updates">Monthly</option>
</select>
</label>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>Tell us a little about yourself <textarea placeholder="Type here">
</textarea>
</label>
</div>
</div>
<div class="row">
<input class="button small large-3" type="submit" name="submit" />
</div>
</form>
Here is my connection to the database/php:
<?php
if(isset($_POST['submit'])){
$con = mysqli_connect("localhost","dxh6110","tcqfoz7","dxh6110")
or die("Error " . mysqli_error($con));
$first = stripslashes($_POST['firstname']);
$last = stripslashes($_POST['lastname']);
$email = stripslashes($_POST['email']);
$checkbox = stripslashes($_POST['products']);
$first = mysqli_real_escape_string($con,$_POST['firstname']);
$last = mysqli_real_escape_string($con,$_POST['lastname']);
$email = mysqli_real_escape_string($con,$_POST['email']);
$checkbox = mysqli_real_escape_string($con,$_POST['products']);
$checkbox = implode(',', $_POST['products']);
$sql = "INSERT INTO Register (Firstname,Lastname,Email,Product)
VALUES('".$firstname."','".$lastname."','".$email."','".$checkbox."')";
}
mysqli_query($con,$sql);
mysqli_close($con);
?>
Well, part of your problem is that every time you visit the page, it will add another row. regardless of a submit or not so add this:
if(isset($_POST['Submit'])){
}
just wrap that around all the php you go there ^.^
so go ahead and delete all the blank rows it got ya and try again. That way you can debug it a little bit better.
So this explains the blank row problem you are having. ;) what of the 3 are not going through?
Welp I have figured my issues out. Thanks all for helping.
Basically when I first posted my issue it was 1 of 3 fields were being submitted to my DB
the reason for this was because my variables were not the same I had it out like this and also I was getting double entries... 1 blank entry and another with the 1 of 3 entries:
$first = stripslashes($_POST['firstname']);
$last = stripslashes($_POST['lastname']);
$email = stripslashes($_POST['email']);
$first = mysqli_real_escape_string($con,$_POST['firstname']);
$last = mysqli_real_escape_string($con,$_POST['lastname']);
$email = mysqli_real_escape_string($con,$_POST['email']);
$sql = "INSERT INTO Register (First,Last,Email,Product,Updates)
VALUES('".$firstname."','".$lastname."','".$email."');
}
$first did not equal $firstname, $last did not equal $lastname $email did equal $email.... so only 1 of 3 were being submitted to the db.
after this issue i didn't know how to add checkboxes and dropdown data... this is what I did to change it and also the double entries (1 blank) thanks to Nate Nevins.
if(isset($_POST['submit'])){
$con = mysqli_connect("localhost","dxh6110","tcqfoz7","dxh6110")
or die("Error " . mysqli_error($con));
$first = stripslashes($_POST['firstname']);
$last = stripslashes($_POST['lastname']);
$email = stripslashes($_POST['email']);
$checkbox = stripslashes($_POST['products']);
$update = stripslashes($_POST['updates']);
$first = mysqli_real_escape_string($con,$_POST['firstname']);
$last = mysqli_real_escape_string($con,$_POST['lastname']);
$email = mysqli_real_escape_string($con,$_POST['email']);
$checkbox = mysqli_real_escape_string($con,$_POST['products']);
$checkbox = mysqli_real_escape_string($con,$_POST['updates']);
$checkbox = implode(',', $_POST['products']);
$sql = "INSERT INTO Register (First,Last,Email,Product,Updates)
VALUES('".$first."','".$last."','".$email."','".$checkbox."','".$update."')";
}
mysqli_query($con,$sql);
mysqli_close($con);
?>

Cannot store radio button value in table

I am trying to save the value of the radio buttons in my database table choice. I get the message Data saved successfully but no value is stored in the table.
Form:
<form id="myForm" method="post" action="">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<center<legend>Choose in which category you'd like to be included</legend></center>
<p><input type="radio" name="choice[]" value="player" id="player" class="custom" />
<label for="player">Player</label>
<input type="radio" name="choice[]" value="coach" id="coach" class="custom" />
<label for="coach">Coach</label>
<input type="radio" name="choice[]" value="supporter" id="supporter" class="custom" />
<label for="supporter">Supporter</label>
<input type="radio" name="choice[]" value="sponsor" id="sponsor" class="custom" />
<label for="sponsor">Sponsor</label>
<input type="radio" name="choice[]" value="alumni" id="alumni" class="custom" />
<label for="alumni">Alumni</label>
<input type="radio" name="choice[]" value="other" id="o" class="custom" />
<label for="o">Other</label>
</fieldset>
</div>
<div data-role="fieldcontain">
<label for="name">Please enter your name:</label>
<input type="text" name="name" id="name" class="required" value="" autocomplete="off" /><br />
<label for="email">Please enter your e-mail:</label>
<input type="text" name="email" id="email" value="" class="required" autocomplete="off" /><br />
<label for="phone">Please enter your phone number:</label>
<input type="number" name="phone" id="phone" value="" class="required" autocomplete="off" />
<br><br>
<label for="other">Other comments</label>
<textarea name="other" id="other" autocomplete="off" placeholder="Anything else you'd like to add?">
</textarea>
<p><strong id="error"></strong></p>
<br><br>
<input type="submit" id="save" name="save" value="Submit Form" />
<p id="response"></p>
</form>
</body>
</html>
PHP:
<?php
$mysqli = new mysqli('localhost', 'root', '', 'E-mail list');
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
if(isset($_POST['save']))
{
$name = $mysqli->real_escape_string($_POST['name']);
$email = $mysqli->real_escape_string($_POST['email']);
$phone = $mysqli->real_escape_string($_POST['phone']);
$other = $mysqli->real_escape_string($_POST['other']);
$choice = $mysqli->real_escape_string($_POST['choice']);
$query = "INSERT INTO Players (`name`,`email`,`phone`,`other`,`choice`) VALUES ('".$name."','".$email."','".$phone."','".$other."','".$choice."')";
if($mysqli->query($query))
{
echo 'Data Saved Successfully.';
}
else
{
echo 'Cannot save data.';
}
}
?>
var_dump($_POST) to sere what data flooding in.
One thing more to check if its save or submit ? in $_POST['save']
EDIT
After getting your full form - the error lies in your center tag
Change <center<legend> TO <center><legend>
The error - ↑ in this tag

Radio Buttons with PHP Form Handling

I have a basic form that I am submitting using some basic PHP. I have the form submission working great, except that I have a radio button (for preferred method of contact) and I am not sure how to add that in the PHP so that sends in the email. Both radio button options have the same name, so that isn't working as the value. My code is below.
The PHP is as follows:
<?php
$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$phone = stripslashes($_POST['phone']);
$contact = stripslashes($_POST['contact']);
$message = stripslashes($_POST['message']);
$form_message = "Name: $name \nEmail: $email \nPhone: $phone \nPreferred Method of Contact: $contact \nMessage: $message";
// Exit process if field "human" is filled (because this means it is spam)
if ( $_POST['human'] ) {
echo 'Tastes Like Spam!'; exit; }
// if it is not filled, submit form
else {
header( "Location: http://www.newurl.com");
mail("myemail#gmail.com", "Email Subject", $form_message, "From: $email" );
}
?>
The HTML for the form is below:
<form method="post" id="form" action="handle_form.php">
<div class="field">
<input type="text" name="human" id="human" class="txt" />
</div>
<div class="field form-inline">
<label class="contact-info" for="txtName">Name*</label>
<input type="text" name="name" id="name" class="txt" value=""/>
</div>
<div class="field form-inline">
<label class="contact-info" for="txtEmail">Email*</label>
<input type="text" name="email" id="email" class="txt" value=""/>
</div>
<div class="field form-inline">
<label class="contact-info" for="txtPhone">Phone</label>
<input type="text" name="phone" id="phone" class="txt" value=""/>
</div>
<div class="field form-inline radio">
<label class="radio" for="txtContact">Preferred Method of Contact</label>
<input class="radio" type="radio" name="contact" checked /> <span>Email</span>
<input class="radio" type="radio" name="contact" /> <span>Phone</span>
</div>
<div class="field form-inline">
<textarea rows="10" cols="20" name="message" id="message" class="txt" value=""></textarea>
</div>
<div class="submit">
<input class="submit" type="submit" name="submit" value="Submit Form">
</div>
</form>
Thanks so much for the help!
<div class="field form-inline radio">
<label class="radio" for="txtContact">Preferred Method of Contact</label>
<input class="radio" type="radio" name="contact" value="email" checked /> <span>Email</span>
<input class="radio" type="radio" name="contact" value="phone" /> <span>Phone</span>
</div>
Note the added value attribute.
And the PHP:
$contact = $_POST['contact']
//Will return either "email" or "phone".
You radios need values:
<input class="radio" type="radio" value="email" name="contact" checked /> <span>Email</span>
<input class="radio" type="radio" value="phone" name="contact" /> <span>Phone</span>
Just give your radio inputs a value-attribute. This is what will get submitted via POST. You can then access it via $_POST['nameofradio']
<input class="radio" type="radio" name="contact" value="Email" checked /> <span>Email</span>
<input class="radio" type="radio" name="contact" value="Phone" /> <span>Phone</span>
Easy! Just add a value to your radio buttons.
<input class="radio" type="radio" name="contact" value="Email" checked /> <span>Email</span>
<input class="radio" type="radio" name="contact" value="Phone" /> <span>Phone</span>

Categories