Insert radio button values in mysql database
Posted: Sat Mar 10, 2012 11:04 pm
Searched all night, all the google sites can't seem to find something that works...or i'm just a complete moron. My radio button values appear in the process page, after submission, but not in the database. The other data appears in the database. The processing page is under construction so i am still searching for a way to recall data from there but until then i need to resolve the radio button problem.
My "edit_profile.html":
"my_profle.php" (page where the data is submitted to):
If someone knows what i need to write and where and wants to give a hand i'll appreciate it...
My "edit_profile.html":
Code: Select all
<html>
<body>
<div id="wb_Form1" style="position:absolute;width:507px;height:393px;">
<form name="my_profile" method="get" action="./my_profile.php" enctype="text/plain" id="Form1">
<div id="wb_Text1" style="position:absolute;left:113px;top:21px;width:163px;height:16px;z-index:65;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">First Name:</span></div>
<input type="text" id="Editbox1" style="position:absolute;left:206px;top:15px;width:198px;height:23px;line-height:23px;z-index:66;" name="fname" value="" maxlength="20" title="Max 20 chars">
<div id="wb_Text2" style="position:absolute;left:121px;top:50px;width:163px;height:16px;z-index:67;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">Last Name:</span></div>
<input type="text" id="Editbox2" style="position:absolute;left:206px;top:45px;width:198px;height:23px;line-height:23px;z-index:68;" name="lname" value="" maxlength="20" title="Max 20 chars">
<div id="wb_Text6" style="position:absolute;left:80px;top:76px;width:168px;height:16px;z-index:69;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;"> Date of birth:</span></div>
<select name="day" size="1" id="Combobox1" style="position:absolute;left:206px;top:75px;width:43px;height:21px;z-index:70;">
<option>01</option>
<option>02</option>
etc
</select>
<select name="month" size="1" id="Combobox2" style="position:absolute;left:250px;top:75px;width:93px;height:21px;z-index:71;">
<option>January</option>
<option>February</option>
etc
</select>
<select name="year" size="1" id="Combobox3" style="position:absolute;left:344px;top:75px;width:61px;height:21px;z-index:72;">
<option>1935</option>
etc
</select>
<div id="wb_Text7" style="position:absolute;left:144px;top:105px;width:163px;height:16px;z-index:73;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">Gender:</span></div>
<input type="radio" id="RadioButton1" name="gender" value="Male" checked style="position:absolute;left:214px;top:106px;z-index:74;">
<div id="wb_Text8" style="position:absolute;left:136px;top:140px;width:163px;height:16px;z-index:75;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">Country:</span></div>
<div id="wb_Text9" style="position:absolute;left:160px;top:171px;width:163px;height:16px;z-index:76;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">City:</span></div>
<input type="text" id="Editbox4" style="position:absolute;left:206px;top:166px;width:198px;height:23px;line-height:23px;z-index:77;" name="city" value="" maxlength="25" title="Max 25 chars">
<div id="wb_Text10" style="position:absolute;left:128px;top:194px;width:163px;height:16px;z-index:78;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">About me:</span></div>
<input type="radio" id="RadioButton2" name="gender" value="Female" style="position:absolute;left:306px;top:106px;z-index:79;">
<div id="wb_Text11" style="position:absolute;left:237px;top:107px;width:48px;height:16px;z-index:80;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">Male</span></div>
<div id="wb_Text12" style="position:absolute;left:330px;top:107px;width:64px;height:16px;z-index:81;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">Female</span></div>
<textarea name="aboutme" id="TextArea1" style="position:absolute;left:205px;top:196px;width:244px;height:81px;z-index:82;" rows="4" cols="26"></textarea>
<input type="reset" id="Button2" name="Reset" value="Reset" style="position:absolute;left:356px;top:363px;width:96px;height:25px;z-index:83;">
<input type="submit" id="Button1" name="submit" value="Submit" style="position:absolute;left:219px;top:364px;width:96px;height:25px;z-index:84;">
<input type="text" id="Editbox5" style="position:absolute;left:206px;top:282px;width:199px;height:22px;line-height:22px;z-index:85;" name="email" value="" maxlength="50" title="Max 50 chars">
<div id="wb_Text14" style="position:absolute;left:144px;top:287px;width:60px;height:16px;z-index:86;">
<span style="color:#EFF3F7;font-family:'Courier New';font-size:13px;">E-mail:</span></div>
<select name="country" size="1" id="Combobox4" style="position:absolute;left:206px;top:138px;width:200px;height:24px;z-index:87;">
<option selected value="Select">Select your country</option>
<option value="Afghanistan">Afghanistan</option>
etc
</select>
</form>
</div>
</body>
</html>Code: Select all
<?php
$con = mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
?>
<?php
$fname = check_input($_GET['fname']);
$lname = check_input($_GET['lname']);
$day = check_input($_GET['day']);
$month = check_input($_GET['month']);
$year = check_input($_GET['year']);
$gender = check_input($_GET['gender']);
$country = check_input($_GET['country']);
$city = check_input($_GET['city']);
$aboutme = check_input($_GET['aboutme']);
$email = check_input($_GET['email'],"Enter your E-mail!");
$sql="INSERT INTO profile (id, FirstName, LastName, Dateofbirth, Gender, Country, City, AboutMe, Email)
VALUES
('$id','$_GET[fname]','$_GET[lname]','$_GET[day], $_GET[month], $_GET[year]','$GET_[gender]','$_GET[country]','$_GET[city]','$_GET[aboutme]','$_GET[email]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
<html>
<body>
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">First Name:</span> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$fname.'</span>'; ?><br /><br />
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">Last Name:</span> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$lname.'</span>'; ?><br /><br />
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">Date of birth:</span> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$day.'</span>'; ?> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$month.'</span>'; ?> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$year.'</span>'; ?><br /><br />
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">Gender:</span> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$gender.'</span>'; ?><br /><br />
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">Country:</span> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$country.'</span>'; ?><br /><br />
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">City:</span> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$city.'</span>'; ?><br /><br />
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">About me:</span><br />
<?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$aboutme.'</span>'; ?><br /><br />
<span style="color:#E3E9F2;font-family:Courier New;font-size:13px;font-weight:bold;">E-mail:</span> <?php echo '<span style="color:#EFF3F7;font-family:Courier New;font-size:13px;">'.$email.'</span>'; ?><br /><br />
</body>
</html>
<?php
function check_input($data, $problem='Fields are not complete')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
die($problem);
}
return $data;
}
?>