这是我的html代码
<?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>
这是我的php代码
<?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);
}
为什么它不存储在数据库中?数据库名称正确,我有3个表
在我的浏览器中,我可以找到index.php,但是当我单击按钮时什么也没发生,任何人都可以解释为什么它不起作用?
答案 0 :(得分:0)
好,问题似乎是由2种重要的错别字引起的:
<from action="index.php.php" method="post">
应该是<form action="index.php" method="post">
。