0

Hi Friends i am trying to isert this data to mysql database. However I cannot get this done because I do not know what is happening.
I would appreciate any help.
This is the code

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
 <body>    
  <div id="wrapper">

        <div class="box-header">
              <h2>NEW USER</h2>
         </div>

           <form action="" method="post">

           <legend>information</legend>

            <fieldset style="float: left; width: 40%">

                <div class="input-group">
                  <div class="input-group-addon">
                    <i class="fa fa-user"></i>
                  </div>
                    <input type="text" name="name"/>
        </div>

                <div class="input-group">
                  </div>
                    <input type="text" name="f_name"/>
        </div>

                <div class="input-group">
                  <div class="input-group-addon">
                    <i class="fa fa-phone"></i>
                  </div>
                    <input type="number" name="phone_no"  class="form-control"/>
          </div>

                  <div class="input-group">
                  <div class="input-group-addon">
                    <i class="fa fa-flag"></i>
                  </div>
                    <select name="country" class="form-control">
            <option value="Albania">Albania</option>
            <option value="Algeria">Algeria</option>
                    </select>
          </div>

                <div class="input-group space">
                  <div class="input-group-addon">
                    <i class="fa-building-o"></i>
                  </div>
                    <input type="text" class="form-control" name="city"/>
          </div>

        <div class="input-group space">
                    <input type="text" class="form-control" name="full_add"/>
                </div>

                <div class="input-group space">
                  <div class="input-group-addon">
                    <i>AGE</i>
                  </div>
                    <input type="number"  name="age"  class="form-control"  required="required"/>
         <select name="age_sc" class="form-control">
                  <option value="Year(s)" selected="selected">Year(s)</option>
                  <option value="Month(s)">Month(s)</option>
                  <option value="Day(s)">Day(s)</option>
                 </select>
        </div>

                  <div class="form-group space">
                   <label>Gender:</label>

                   <label>Male</label>
                    <input type="radio" name="gender" value="Male"/>
                    <label>Female</label>
                    <input type="radio" name="gender" value="Female"/>
        </div>

            </fieldset>

            <fieldset style="float: right; width: 40%; margin-right: 100px">

         <label>Problem</label>
              <input type="text" class="form-control" name="problem"/>

                <label class="space">visit</label>
                <?php
                     $query = "SELECT * from P_table";
             $result = mysqli_query($con, $query);
        ?>
        <select name="visit" id="visit"class="form-control">
                    <option value="0">Please select</option>
        <?php
                    while ($row= mysqli_fetch_assoc($result)) {
            $id = $row['u_id'];
            $vist_to = $row['visit_to'];
        ?>
    <option value="<?php echo $id; ?>"> <?php echo $vist_to;?></option>
    <?php } ?>
              </select>

                <label> Doctor:</label>
                    <select name="doc"><option>Doctor Name</option>
                      <option>Dr.Henry</option>
                      <option>Dr.Menro</option></select>

                  <div class="input-group">
                    <label>Fees:</label>
                    <div class="input-group">
                    <input type="text" name="crncy" id="curncy"/>
            <input type="text" name="fee" id="fee" />
           </div>
        </div>

              <!-- Date and time range -->

              <div class="form-group">
                <label>Date and time</label>

                <div class="input-group">
                  <div class="input-group-addon">
                    <i class="fa fa-clock-o"></i>
                  </div>
                  <input type="text" name="date" id="reservationtime">
                </div>
                <!-- /.input group -->
              </div>
              <!-- /.form group -->

            </fieldset>

            <div class="clear"></div>
                          <input type="submit"  name="submit" value="submit" />  

              <div class="clear"></div>         
    </form>

</div><!--End of wrapper-->
</body>
</html>

php code is here

<?php
            include("connection.php");

    if(isset($_POST['submit']))
    {
        $name = $_POST['name'];
        $f_name = $_POST['f_name'];
        $phone_no = $_POST['phone_no'];
        $country = $_POST['country'];
        $city = $_POST['city'];
        $add = $_POST['full_add'];
        $age = $_POST['age'];
        $age_sc = $_POST['age_sc'];
        $gender = $_POST['gender'];
        $prob = $_POST['problem'];
        $visit = $_POST['visit'];
        $doct = $_POST['doc'];
        $fee = $_POST['fee'];
        $crncy = $_POST['crncy'];
        $a_date = $_POST['date'];

        $insert = "insert into new_table (name,f_name,contact,country,city,address,age,age_sc,gender,problem,visit,doc,fee,currency,date,c_date) values('$name','$f_name','$phone_no','$country','$city','$add','$age','$age_sc','$gender','$prob','$doct','$fee','$crncy','$a_date',NOW())";

        $qur = mysqli_query($con, $insert);

        if($qur)
        {
           echo"<script>alert('Added Successfully')</script>";
           echo"<script>window.open('index.php','_self')</script>";
           }
        else{
            echo "<h2>Data not inserted </h2>";
        }

    }
        ?>

Edited by Sameer_10

2
Contributors
1
Reply
22
Views
1 Month
Discussion Span
Last Post by patk570
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.