Problem in php web

Hi guys. Im new to php so im not really sure what i am doing. I have this website that has two (2) registration form but the thing is. i dont know why i cant insert it into my database. it always says undefined index. here is the first part of the registration form

[code]<?php

session_start();
?>

Untitled Document

Medical Record

First Name Last Name MI

Date Of Birth Age Civil Status

Baguio Address

 

Designation: Student Faculty Ants Dependent

Department

If Student: Course Year:

Contact Persion in case of emergency:

A. Name B.

Adress

Tell No.

Relationship

[/code]

and 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.

[code]<?php
mysql_connect(“localhost”,“root”,"");

mysql_select_db(“database”);

?>

<?php session_start(); $_REQUEST['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']; $_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 $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 ('$_SESSION[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); ?>

[/code]
any help would be appreciated :slight_smile:

Ok without looking through your whole code, You seem to be tryin to pass data to the final form from both current forms right?

However, You haven’t passed data from form1 to form2 so after form2 the data from form1 isn’t valid anymore.

If I am correct the undefined indexes you have are:
fname
Lastname
mname
DoB
age
CivilStatus
BagAddress
Designation
department
course
year
Ename
emname
eaddress
emaddress
eTellNo
emTellNo
eRelationship
emRelationship

Also in your final code:
$_SESSION[‘mname’] = $_POST[’$mname’];

should be

$_SESSION[‘mname’] = $_POST[‘mname’];

Sponsor our Newsletter | Privacy Policy | Terms of Service