Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    problem inserting button to sql

    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
    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
    Last edited by impacter; 11-18-2011 at 03:08 PM.

  • #2
    New Coder
    Join Date
    Feb 2006
    Location
    Texas
    Posts
    80
    Thanks
    1
    Thanked 8 Times in 8 Posts
    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
    PHP Code:
    "values( '{$_SESSION['fname']}', .. 

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Truffle View Post
    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
    PHP Code:
    "values( '{$_SESSION['fname']}', .. 
    i have tried that but it still says Undefined index: (starting with) Allergy until Bloodtype which is the last one..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •