impacter
11-21-2011, 06:48 AM
Hi guys. im creating a website that has a multiple registration forms but the thing is, it always says undefined index. here is my code btw.. im new to php so i cant figure out whats wrong with my problem.
for the first form
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="regdiv2">
<h3>Medical Record</h3>
<form id="form1" name="form1" method="post" action = "reg2.php">
<p>First Name
<input type="text" name="fname"/>
Last Name
<input type="text" name="Lastname"/>
MI
<input type="text" name="mname"/>
</p>
<p>Date Of Birth
<input type="text" name="DoB"/>
Age
<input type="text" name="age"size = "5"/>
Civil Status
<input type="text" name="CivilStatus"/>
</p>
<p>Baguio Address
<input type="text" name="BagAddress"size = "80"/>
</p>
<p> </p>
<p>Designation: Student
<input type="checkbox" name="Designation"/>
Faculty
<input type="checkbox" name="Designation"/>
Ants
<input type="checkbox" name="Designation"/>
Dependent
<input type="checkbox" name="Designation"/>
</p>
<p>Department
<input type="text" name="department" size = "50"/>
</p>
<p>If Student: Course
<input type="text" name="course"/>
Year:
<input type="text" name="year"/>
</p>
<p>Contact Persion in case of emergency:</p>
<p>A. Name
<input type="text" name="Ename"/>
B.
<input type="text" name="emName"/>
</p>
<p>Adress
<input type="text" name="eaddress"/>
<input type="text" name="emAddress"/>
</p>
<p>Tell No.
<input type="text" name="eTellNo"/>
<input type="text" name="emTellNo"/>
</p>
<p>Relationship
<input type="text" name="eRelationship" />
<input type="text" name="emRelationship" />
</p>
<p>
<input type="submit" name="next" value=" Next "/>
</p>
</form>
</div>
<div id="regdiv1">
<img src="image/register.jpg"/></div>
</body>
</html>
here is the second
<?php
session_start();
$_SESSION['fname'];
?>
<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="insertdata.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>ID Number
<input type="text" name="IdNum" >
</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>
and finally
<?php
mysql_connect("localhost","root","");
mysql_select_db("softeng");
?>
<?php
session_start();
$_SESSION['fname'] = $_POST['lname'];
$_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'];
$_SESSION['Allergy'] = $_POST['Allergy'];
$_SESSION['Allergy1'] = 'Allergy1';
$_SESSION['Asthma'] = $_POST['Asthma'];
$_SESSION['seizure'] = $_POST['seizure'];
$_SESSION['Heast'] = $_POST['Heast'];
$_SESSION['Diabetese'] = $_POST['Diabetese'];
$_SESSION['BP'] = $_POST['BP'];
$_SESSION['temp'] = $_POST['temp'];
$_SESSION['height'] = $_POST['height'];
$_SESSION['weight'] = $_POST['weight'];
$_SESSION['Bloodtype'] = $_POST['Bloodtype'];
$_SESSION['IdNum'] = $_POST['IdNum'];
?>
<?php
//let's start our session, so we have access to stored data
//let's create the query
if(isset($_REQUEST['submit']))
{
$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, Idnum ) 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', '$IdNum')";
mysql_query($query);
}
?>
any help would be appreciated. :)
for the first form
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="regdiv2">
<h3>Medical Record</h3>
<form id="form1" name="form1" method="post" action = "reg2.php">
<p>First Name
<input type="text" name="fname"/>
Last Name
<input type="text" name="Lastname"/>
MI
<input type="text" name="mname"/>
</p>
<p>Date Of Birth
<input type="text" name="DoB"/>
Age
<input type="text" name="age"size = "5"/>
Civil Status
<input type="text" name="CivilStatus"/>
</p>
<p>Baguio Address
<input type="text" name="BagAddress"size = "80"/>
</p>
<p> </p>
<p>Designation: Student
<input type="checkbox" name="Designation"/>
Faculty
<input type="checkbox" name="Designation"/>
Ants
<input type="checkbox" name="Designation"/>
Dependent
<input type="checkbox" name="Designation"/>
</p>
<p>Department
<input type="text" name="department" size = "50"/>
</p>
<p>If Student: Course
<input type="text" name="course"/>
Year:
<input type="text" name="year"/>
</p>
<p>Contact Persion in case of emergency:</p>
<p>A. Name
<input type="text" name="Ename"/>
B.
<input type="text" name="emName"/>
</p>
<p>Adress
<input type="text" name="eaddress"/>
<input type="text" name="emAddress"/>
</p>
<p>Tell No.
<input type="text" name="eTellNo"/>
<input type="text" name="emTellNo"/>
</p>
<p>Relationship
<input type="text" name="eRelationship" />
<input type="text" name="emRelationship" />
</p>
<p>
<input type="submit" name="next" value=" Next "/>
</p>
</form>
</div>
<div id="regdiv1">
<img src="image/register.jpg"/></div>
</body>
</html>
here is the second
<?php
session_start();
$_SESSION['fname'];
?>
<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="insertdata.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>ID Number
<input type="text" name="IdNum" >
</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>
and finally
<?php
mysql_connect("localhost","root","");
mysql_select_db("softeng");
?>
<?php
session_start();
$_SESSION['fname'] = $_POST['lname'];
$_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'];
$_SESSION['Allergy'] = $_POST['Allergy'];
$_SESSION['Allergy1'] = 'Allergy1';
$_SESSION['Asthma'] = $_POST['Asthma'];
$_SESSION['seizure'] = $_POST['seizure'];
$_SESSION['Heast'] = $_POST['Heast'];
$_SESSION['Diabetese'] = $_POST['Diabetese'];
$_SESSION['BP'] = $_POST['BP'];
$_SESSION['temp'] = $_POST['temp'];
$_SESSION['height'] = $_POST['height'];
$_SESSION['weight'] = $_POST['weight'];
$_SESSION['Bloodtype'] = $_POST['Bloodtype'];
$_SESSION['IdNum'] = $_POST['IdNum'];
?>
<?php
//let's start our session, so we have access to stored data
//let's create the query
if(isset($_REQUEST['submit']))
{
$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, Idnum ) 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', '$IdNum')";
mysql_query($query);
}
?>
any help would be appreciated. :)