...

View Full Version : problem inserting button to sql



impacter
11-18-2011, 02:52 PM
Hi guys. I'm having problem inserting radio button in sql using php it and i dont know why. could someone please help me? here is my code


<?php
$con=mysql_connect("localhost","root","");

mysql_select_db("database");


?>


<?php
//let's start the session
session_start();
//now, let's register our session variables

//finally, let's store our posted values in the session variables
$_SESSION['fname'] = $_POST['fname'];
$_SESSION['lname'] = $_POST['lname'];
$_SESSION['mname'] = $_POST['mname'];
$_SESSION['DoB'] = $_POST['DoB'];
$_SESSION['age'] = $_POST['age'];
$_SESSION['CivilStatus'] = $_POST['CivilStatus'];
$_SESSION['BagAddress'] = $_POST['BagAddress'];
$_SESSION['Designation'] = $_POST['Designation'];
$_SESSION['department'] = $_POST['department'];
$_SESSION['course'] = $_POST['course'];
$_SESSION['year'] = $_POST['year'];
$_SESSION['Ename'] = $_POST['Ename'];
$_SESSION['eaddress'] = $_POST['eaddress'];
$_SESSION['emAddress'] = $_POST['emAddress'];
$_SESSION['eTellNo'] = $_POST['eTellNo'];
$_SESSION['emTellNo'] = $_POST['emTellNo'];
$_SESSION['eRelationship'] = $_POST['eRelationship'];
$_SESSION['emRelationship'] = $_POST['emRelationship'];
$allergy = $_POST["Allergy"];
$allergy1 = $_POST["Allergy1"];
$_Astha = $_POST["Asthma"];
$seizure = $_POST["seizure"];
$Heast = $_POST["Heast"];
$Diabetese = $_POST["Diabetese"];
$BP = $_POST["BP"];
$temp = $_POST["temp"];
$height = $_POST["height"];
$weight = $_POST["weight"];
$Bloodtype = $_POST["Bloodtype"];



?>
<?php
//let's start our session, so we have access to stored data
//let's create the query
if(isset($RegSubmit))
$query = "insert into stud (fname, lname, mname, DoB, age, CivilStatus, BagAddress, Designation, department, course, year, Ename, eAddress, emAddress, eTellNo, emTellNo, eRelationship, emRelationship, Allergy, Allergy1, Asthma, seizure, Heast, Diabetese, BP, temp, height, weight, Bloodtype) values ('$fname', '$lname', '$mname', '$DoB', '$age', '$CivilStatus', '$BagAddress', '$Designation', '$department', '$course', '$year', '$Ename', '$eAddress', '$emAddress', '$eTellNo', '$emTellNo', '$eRelationship', '$emRelationship', 'Allergy', 'Allergy1', 'Asthma', 'seizure', 'Heast', 'Diabetese', 'BP', 'temp', 'height', 'weight', 'Bloodtype')";
mysql_query($query);


?>
<html>
<head>
<title></title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</style>
</head>

<body>
<div id="regdiv2">
<h3>Medical Record</h3>
<p>Medical History:</p>
<form id="form1" name="form1" method="post" action="reg2.php">
<p>A. Allergy to drugs:
<input type="radio" name="Allergy" value="Yes" />
Yes
<input type="radio" name="Allergy" value="No" />
No </p>
<p>If yes, state the name(s) of drug(s) you are allergic to:
<input type="text" name="allergy1" />
</p>
<p>B. Asthma
<input type="radio" name="Asthma" value="Yes" />
Yes
<input type="radio" name="Asthma" value="No" />
No </p>
<p>C. Seizures/Comvulsion/Epilepsy
<input type="radio" name="seizure" value="Yes" />
Yes
<input type="radio" name="seizure" value="No" />
No </p>
<p>D. Heastdisease
<input type="radio" name="Heast" value="Yes" />
Yes
<input type="radio" name="Heast" value="No" />
No </p>
<p>E. Diabetese
<input type="radio" name="Diabetese" value="Yes" />
Yes
<input type="radio" name="Diabetese" value="No" />
No </p>
<p>Vital Sign: BP
<input type="text" name="BP" size = "5" />
MMHG Temp
<input type="text" name="temp" size = "5" />
Height
<input type="text" name="height" size = "5"/>
ft.
weight
<input type="text" name="weight" size = "5"/>
lbs</p>
<p>Blood Type:
<input type="radio" name="Bloodtype" value="bloodtypeA" />
A
<input type="radio" name="BloodType" value="BloodTypeB" />
B
<input type="radio" name="BloodType" value="BloodTypeAB" />
AB
<input type="radio" name="BloodType" value="BloodTypeO" />
O</p>
<p>
<input type="submit" name="RegSubmit" value="Submit" />
</p>
</form>
</div>
<div id="regdiv1"><img src="image/register.jpg" width="900" height="1000" /></div>
</body>
</html>



i used $_SESSION because i have two registration page so i stored the other information in there.. any help would be great. xD

Truffle
11-18-2011, 03:12 PM
looks like you have variables in your sql statement that do not exists such as $fname

The correct variable to use for that in this case is $_SESSION['fname']
It could look like this inside the sql statement quotes


"values( '{$_SESSION['fname']}', ..

impacter
11-18-2011, 03:18 PM
looks like you have variables in your sql statement that do not exists such as $fname

The correct variable to use for that in this case is $_SESSION['fname']
It could look like this inside the sql statement quotes


"values( '{$_SESSION['fname']}', ..


i have tried that but it still says Undefined index: (starting with) Allergy until Bloodtype which is the last one.. :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum