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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?