0

I am making a simple survey form using html and i am trying to insert the data in mysql database my form is full of radio buttons whenever i try to insert data in my table it gives me error of unidentified variable yet data is inserted in my table with zeros before i could enter anything HERE IS THE HTML CODE

<html>
<H1>FEEDBACK FORM</H1>
</head>
<body>
<form method="post" action="journal.php" >
Q.1. How much do you rate the User Interface of our application? <br>
<input type="radio" name="q1" value="1">1 
<input type="radio" name="q1" value="2">2 
<input type="radio" name="q1" value="3">3
<input type="radio" name="q1 value="4">4 
<input type="radio" name="q1" value="5">5 <br> <br>
Q.2. How much do you rate the comfort of our usage? <br>
<input type="radio" name="q2"value="1">1 
<input type="radio" name="q2"value="2">2 
<input type="radio" name="q2" value="3">3
<input type="radio" name="q2"  value="4">4 
<input type="radio" name="q2"  value="5">5 <br><br> 
Q.3. How much do you rate the level design of ACROPHOBIA(FEAR OF HEIGHTS)?<br>
<input type="radio" name="q3"  value="1">1 
<input type="radio" name="q3"  value="2">2 
<input type="radio" name="q3"  value="3">3
<input type="radio" name="q3"  value="4">4 
<input type="radio" name="q3"  value="5">5 <br> <br>
Q.4. How much do you rate the level design of NYCTOPHOBIA(FEAR OF DARKNESS)?<br>
<input type="radio" name="q4"  value="1">1 
<input type="radio" name="q4"  value="2">2 
<input type="radio" name="q4"  value="3">3
<input type="radio" name="q4"  value="4">4 
<input type="radio" name="q4"  value="5">5 <br><br>
Q.5.  How much do you rate the level design of PHASMOPHOBIA(FEAR OF GHOSTS)? <br>
<input type="radio" name="q5"  value="1">1 
<input type="radio" name="q5"  value="2">2 
<input type="radio" name="q5"  value="3">3
<input type="radio" name="q5"  value="4">4 
<input type="radio" name="q5"  value="5">5 <br><br> 
Q.6. Please rate your level of anxiety throughout the experince <br>
<input type="radio" name="q6" value="1">1 
<input type="radio" name="q6" value="2">2 
<input type="radio" name="q6" value="3">3
<input type="radio" name="q6" value="4">4 
<input type="radio" name="q6" value="5">5 <br> <br> 
Q.7. Please rate the overall experince of our application <br>
<input type="radio" name="q7" value="1">1 
<input type="radio" name="q7"  value="2">2 
<input type="radio" name="q7"  value="3">3
<input type="radio" name="q7"  value="4">4 
<input type="radio" name="q7"  value="5">5 <br><br> 
Q.8. How many sessions do you think you need in order to overcome the PHOBIA UNDER PROFESSIONAL GUIDANCE?<br>
<input type="radio" name="q8"  value="1">less than 8 sessions 
<input type="radio" name="q8" value="2">8-10 sessions
<input type="radio" name="q8"  value=3">12-14 sessions
<input type="radio" name="q8"  value="4">more than 14 sessions 
<input type="radio" name="quest_8"  value="5">I dont think this would work <br><br>
Q.9. Would you like to use this application to overcome your PHOBIA?<br>
<input type="radio" name="q9"  value="1">Yes
<input type="radio" name="q9"  value="2">No I dont think so<br><br>
<input type="submit" name="submit" value="Submit The Form">
</body>
</html>
HERE IS THE PHP CODE
<?php
$con=mysqli_connect('127.0.0.1','root','');
if(!$con)
    {
        echo 'Not connected to server';
    }
if(mysqli_select_db($con,'feedback'))
    {
        echo 'Database  selected';
    }
    if (isset($_POST['submit']))
       { if ( isset($_POST['q1']))
    {$q1=$_POST['q1'];}
    if (isset($_POST['q2']))
    {$q2=$_POST['q2'];}
        if(isset($_POST['q3'])) 
    {$q3=$_POST['q3'];}
        if(isset($_POST['q4']))
    {$q4=$_POST['q4'];}
        if(isset($_POST['q5']))
    {$q5=$_POST['q5'];}
        if(isset($_POST['q6']))
    {$q6=$_POST['q6'];}
        if(isset($_POST['q7']))
    {$q7=$_POST['q7'];}
        if(isset($_POST['q8']))
    {$q8=$_POST['q8'];}
        if(isset($_POST['q9']))
    {$q9=$_POST['q9'];}
        }
    $sql="INSERT INTO survey (QUESTION_1,QUESTION_2,QUESTION_3,QUESTION_4,QUESTION_5,QUESTION_6,QUESTION_7,QUESTION_8,QUESTION_9) VALUES ('$q1','$q2','$q3','$q4','$q5','$q6','$q7','$q8','$q9') ";
    if (!mysqli_query($con,$sql))
    {   echo 'Not Inserted';
    }
    else
    echo 'Value inserted';
    header("refresh:10; url=form.html");
?>














?>
DPJ
  • 1
  • 3
  • `submit` != `Submit`. Those are 2 different animals. – Funk Forty Niner Mar 28 '16 at 02:09
  • damit @Fred-ii- i wanted to close it :-) –  Mar 28 '16 at 02:10
  • 1
    *Missed it by "that" much* @Dagon (I won't take the credit from Max). – Funk Forty Niner Mar 28 '16 at 02:11
  • I changed the 'submit' thing but still still shows an error Notice: Undefined variable: q1 in C:\xampp\htdocs\project\journal.php on line 31 Notice: Undefined variable: q2 in C:\xampp\htdocs\project\journal.php on line 31 and it continues till q9 please help!!!!!! – DPJ Mar 28 '16 at 08:47

0 Answers0