เพิ่มข้อมูลไม่ขึ้น error แต่ไม่ลงฐานข้อมูลค่ะ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา เพิ่มข้อมูลไม่ขึ้น error แต่ไม่ลงฐานข้อมูลค่ะ

เพิ่มข้อมูลไม่ขึ้น error แต่ไม่ลงฐานข้อมูลค่ะ
dbconnect.php

<?php
    $servername = 'localhost';
    $username = 'root';
    $password = 'earn8225';
    $db = 'gout';

    //Create connection
    $conn = new mysqli($servername, $username, $password, $db);

    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $conn->set_charset('utf8');
?>

page1.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <link rel="stylesheet" type="text/css" href="js/fonts/font_roboto/roboto.css"/>
  	<link rel="stylesheet" type="text/css" href="js/dhtmlxcalendar.css"/>
    <link rel="stylesheet" type="text/css" href="css.css">
  	<script src="js/dhtmlxcalendar.js"></script>
    <title>Case Record form</title>
  </head>

   
<script language="JavaScript" type="text/javascript"
    xml:space="preserve">

 var today = new Date()
   function listdate()
    {
   if (form1.month.selectedIndex==1)
   {
   if((form1.year.selectedIndex 2)%4==0)
   {
   if(form1.date.selectedIndex>28)
   form1.date.selectedIndex=28
}
else
if(form1.date.selectedIndex>27)
form1.date.selectedIndex=27
}
else if (form1.month.selectedIndex==3||form1.month.selectedIndex==5||form1.month.selectedIndex==8||form1.month.selectedIndex==10)
{
if(form1.date.selectedIndex>29)
form1.date.selectedIndex=29
}
else
{
//
}
if(today.getMonth()>form1.month.selectedIndex)
{
form1.txtage.value=today.getFullYear() 543-form1.year.selectedIndex-2455
}
else if (today.getMonth()==form1.month.selectedIndex)
{
if(today.getDate()>=form1.date.selectedIndex 1)
form1.txtage.value=today.getFullYear() 543-form1.year.selectedIndex-2455
else
form1.txtage.value=today.getFullYear() 543-form1.year.selectedIndex-2456
}
else
{
form1.txtage.value=today.getFullYear() 543-form1.year.selectedIndex-2456
}
}
</script>
  <body >
   <div class = "wrap">
    <form onSubmit="return checkrequired(this)" action="page2.php" method="post" id="form1" name="form1">
      <h2> Case Record form </h2> <br>

      <b>Date of birth</b> <select name="requiredday" id="date" onchange="listdate()">
        <option> day </option>
        <script type ="text/javascript">
      for(inti= 1;inti<=31;inti++)
      document.write("<option value ='" + inti + "'>"+inti + "</option>");
        </script>

      </select>
      <label for="month"></label>
      <select name="requiredmonth" id="month" onchange ="listdate()">
        <option> month </option>
        <option value="m1">January</option>
        <option value="m2">February</option>
        <option value="m3">March</option>
        <option value="m4">April</option>
        <option value="m5">May</option>
        <option value="m6">June </option>
        <option value="m7">July </option>
        <option value="m8">August </option>
        <option value="m9">September </option>
        <option value="m10">October </option>
        <option value="m11">November </option>
        <option value="m12">December </option>
      </select>
      <label for="year"></label>
      <select name="requiredyear" id="year" onchange="listdate()">
      <option> year </option>
        <script type ="text/javascript">
      for(inti= 2455;inti<=2562;inti++)
      document.write("<option value ='" + inti + "'>"+inti + "</option>");
        </script>
      </select><br>
     Age :
      <label for="txtage">
      <input name="txtage" type="text" id="txtage" size="10" /><br>

      <!-- <b>Date of birth</b> : <input type="text" value="00-00-0000" name="date_start" id="date_start"> <span><img id="calendar_start" src="images/calendar.png" border="0"></span><br> -->
      <b>Date of visit</b> <input type="text" value="<?php echo date ("d-m-Y") ?>" /> <br>

      <?php
        date_default_timezone_set('Asia/Bangkok');
        $current_date = date('H:i:s')
      ?>

      <span style="font-size:18px;"> <b> Time visit ER  </b> </span>
      <input type="text"  name="date"  id="date" value="<?php echo $current_date?>"/>
      <br>
      <br>

      <span style="font-size:18px;"> <b> Sex: </b> </span>
      <input type ="radio" name="sex" value ="male" > Male
      <input type ="radio" name="sex" value ="female" > Female
      <br>
      <br>

      <span style="font-size:18px;"> <b> Race: </b> </span>
      <input type ="radio" name="race" value ="Not African-American" > Not African-American
      <input type ="radio" name="race" value ="African-American" > African-American
      <br>
      <br>

      <span style="font-size:18px;"> <b> Body weight </b> </span>
      <select name="requiredweight">
        <option> weight </option>
        <?php
          for($i = 10; $i <= 150;$i++) {
            echo "<option value=$i> $i</option>";
          }
        ?>
      </select>
      <span style="font-size:16px;"> kg </span>
      <br>
      <br>

      <span style="font-size:18px;"> <b> Height </b> </span>
      <input type="text" name="requiredheight">
      <span style="font-size:16px;"> m </span>
      <br>
      <br>


      <?php
        include 'dbconnect.php';


      if(isset($_POST['submit']))
        {
          $sql = "INSERT INTO test (`age`, `sex`)
          VALUES ('".$_POST["txtage"]."','".$_POST["sex"]."')";

          $result = mysqli_query($conn,$sql);
        }
      ?>


      <input type ="submit" value ="Enter" name="submit">

    </form>


  </div>
  </body>
</html>


ณัฐริกา บุญมา 49.231.30.xxx 08-08-2019 23:01:44

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
ตรวจสอบ และ debug ไฟล์ที่ฟอร์มส่ง action ไป ดูแนวทางจาก จากบทความด้านล่าง


บทความแนะนำที่เกี่ยวข้อง
แนวทางตรวจสอบ error การเชื่อมต่อ และการคิวรี่ข้อมูลจาก databaseอ่าน 43,122
ninenik 122.155.47.xxx 09-08-2019






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ