dtncv04228 2018-09-06 09:59
浏览 59
已采纳

简单的php数据库连接不会连接数据库? [关闭]

this is my html code

<?php include('process.php') ?>
<!doctype html>
<html lang="en">
  <head>
    <title>Title</title>

  </head>
  <body>

  <from action="index.php.php" method="post">
  <?php include('errors.php'); ?>

  <lable> name </lable>
  <input  type="text" name="name" placeholder="enter your name"> 


  <lable>location</lable>
  <input  type="text" name="location"  placeholder="enter your location">

  <button type="submit" name="save_btn" >update</button>

  </from>

  </body>
</html>

this is my php code

<?php
session_start();

// initializing variables
$name="";
$location="";


// connect to the database
$db = mysqli_connect('localhost', 'newuser', 'password', 'curd');

// REGISTER USER
if (isset($_POST['save_btn'])) {
  // receive all input values from the form
  $name = mysqli_real_escape_string($db, $_POST['name']);
  $location = mysqli_real_escape_string($db, $_POST['location']);


    $query = "INSERT INTO data (name, location) VALUES('$name', '$location')";

   mysqli_query($db, $query);


}

why its not store in data base? data base name correct and i have 3 tables

  1. id (ai)
  2. name (var 200)
  3. location (var 200)

in my browser i can locate index.php but when i click button nothing happen any one can explain why its not working?

  • 写回答

1条回答 默认 最新

  • dongxie2756 2018-09-06 10:06
    关注

    Fine, it seems that the problem is caused by 2 important typos:

    <from action="index.php.php" method="post"> should be <form action="index.php" method="post">.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何实现从tello无人机上获取视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决