Inserting questions and answertype in database submit button cannot be read

89 Views Asked by At

This is basically a survey system and I'm inserting the questions that I just answered but my submit button cannot be read since when I ran the program it wasn't doing anything when I was pressing the submit button.

I've been trying to move the </form> tag but I still get the problem.

<html lang="en">    
<head>
</head
<body>
<?php include("navigation.php") ?>
<form method="POST" > 
<div class="col-lg-12">
        <div class="col-lg-6">

            <center>
        <label>Name</label><input type="text" class="form-control" name="name" > </br>
               <label>Age</label><input type="text" class="form-control" name="age" > </br>
                      <label>Gender</label><input type="text" class="form-control" name="gender" > </br>
                             <label>Email Address</label><input type="text" class="form-control" name="email" > </br>
       </center>            
        </div>
    </div>
    <div class="container">
    <?php
require("testdb.php");  
    $id = $_REQUEST['survey_id'];
    $count=1;
    $query = mysqli_query($con, "SELECT * FROM tempquestions WHERE survey_id='".$id."'"); 
    if(mysqli_num_rows($query) > 0){
     while($row = mysqli_fetch_array($query)){
        $questions = $row['question'];
        $answers = "<input type='radio' name='answer".$count."' value='yes'>Yes <input type='radio' name='answer".$count."' value='no'>No <input type='radio' name='answer".$count."' value='maybe'> Maybe<br>
        ";
        echo "<b>Question ". $count.".)</b> ". $questions. "</br>".$answers;
        $count++;
            }   
     }
    ?>
    </div>
                            <input type="button" class="btn btn-info" name="submit" value="submit">                  
<?php
    if(isset($_POST['submit'])){
        $name = $_POST['name'];
        $age = $_POST['age'];
        $gender = $_POST['gender'];
        $email = $_POST['email'];
        $q1 = $_POST['answer'];
        $q2 = $_POST['answer'];
        $q3 = $_POST['answer'];
        $q4 = $_POST['answer'];
        $q5 = $_POST['answer'];
        $q6 = $_POST['answer'];
        $q7 = $_POST['answer'];
        $q8 = $_POST['answer'];
        $q9 = $_POST['answer'];
        $q10 = $_POST['answer'];

        $query = mysqli_query($con, "INSERT into results VALUES ('','$name','$age','$gender,'$email,'$q1','$q2','$q3','$q4','$q5','$q6','$q7','$q8','$q9','$q10')");
        if(!$query){
            echo mysqli_errno();
        }
        else{
            echo "Survey submitted!";
        }
}
    ?>
 </form> there is something wrong here?
</body>
 <!-- /.container -->`enter code here`

    <!-- jQuery Version 1.11.1 -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

</html>
2

There are 2 best solutions below

2
On BEST ANSWER

its not worked because your input type is a button change this to the submit

                            <input type="submit" class="btn btn-info" name="submit" value="submit">
0
On

Change your button type

from this

<input type="button"

to this

<input type="submit"