Php 提交按钮不会将表单数据发送到MySQL数据库
我有一个问题,可能是语法问题,但我似乎无法找出我做错了什么。 我已经创建了一个表单,当我单击submit时,表单中的数据不会发送到我的mysql数据库 这是我的html代码Php 提交按钮不会将表单数据发送到MySQL数据库,php,html,Php,Html,我有一个问题,可能是语法问题,但我似乎无法找出我做错了什么。 我已经创建了一个表单,当我单击submit时,表单中的数据不会发送到我的mysql数据库 这是我的html代码 <div class="content-wrapper"> <div class="container"> <div class="row"> <div class="col-md-10"> <h1 class="page-head
<div class="content-wrapper">
<div class="container">
<div class="row">
<div class="col-md-10">
<h1 class="page-head-line">Forms </h1>
</div>
</div>
<div class="row">
<div class="col-md-10">
<div class="panel panel-default">
<div class="panel-heading">
BASIC FORM ELEMENTS
</div>
<div class="panel-body">
<form method="post" action="insert.php" >
<div class="form-group">
<label for="name">Name</label>
<input name="name' type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
<div class="form-group">
<label for="project_num">OIT-GIS Project Number</label>
<input name="project_num' type="text" class="form-control" id="project_num" placeholder="OIT-GIS Project Number" />
</div>
<div class="form-group">
<label for="project_name">Project Name</label>
<input name="name' type="text" class="form-control" id="project_name" placeholder="Project Name" required/>
</div>
<div class="form-group">
<label for="easyvista">EasyVista Ticket Number</label>
<input name="easyvista' type="text" class="form-control" id="easyvista" placeholder="EasyVista Ticket Number" />
</div>
<div class="form-group">
<label for="agency">Requestor/Agency</label>
<input name="agency' type="text" class="form-control" id="agency" placeholder="Requestor or Agency" />
</div>
<div class="form-group">
<label for="description">Description of Work:</label>
<input name="description' type="text" class="form-control" id="agency" placeholder="Description" />
</div>
<div class="form-group">
<label for="input-date">Enter Today Date</label>
<input name="input-date' type="date" value="">
<span class="result"></span>
</div>
<div class="form-group">
<div class="col-md-10">
<input id="submit" name="submit" type="submit" class="btn btn-primary">
</div>
</div>
</form>
</div>
</div>
这是我的php
<?php
echo $POST;
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("../includes/config.php");
if (isset($_POST['submit'])) {
echo $_POST['submit'];
$name = $_POST['name'];
$projectnum = $_POST['project_num'];
$projectname = $_POST['project_name'];
$easyvista = $_POST['easyvista'];
$agency = $_POST['agency'];
$description = $_POST['description'];
$startDate = $_POST['input-date'];
$sql="INSERT INTO statusreport(name, project_num, project_name, easyvista, agency, description)
VALUES
('$name','$projectnum', '$projectname', '$easyvista', '$agency', '$description')";
if (!mysqli_query($conn, $sql))
{
die('Error: ' . mysqli_connect_error($conn));
}
echo "Entry is recored <br/>";
echo "Name:", $name, "<br/>";
echo "test..................<br/>", $name;
/*header("location: http://10.1.7.129//gisadmin/admin/forms.php");*/
//echo "<script>setTimeout(\"location.href = 'http://10.1.7.129//gisadmin/admin/forms.php';\",700);</script>";
mysqli_query($conn, $sql);
}
else {
echo "No data";
}
?>
任何帮助都将不胜感激。
谢谢这里混合了单引号和双引号,名称属性用双引号打开值,用单引号关闭值,应如下所示:
<form method="post" action="insert.php" >
<div class="form-group">
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
<div class="form-group">
<label for="project_num">OIT-GIS Project Number</label>
<input name="project_num" type="text" class="form-control" id="project_num" placeholder="OIT-GIS Project Number" />
</div>
<div class="form-group">
<label for="project_name">Project Name</label>
<input name="project_name" type="text" class="form-control" id="project_name" placeholder="Project Name" required/>
</div>
<div class="form-group">
<label for="easyvista">EasyVista Ticket Number</label>
<input name="easyvista" type="text" class="form-control" id="easyvista" placeholder="EasyVista Ticket Number" />
</div>
<div class="form-group">
<label for="agency">Requestor/Agency</label>
<input name="agency" type="text" class="form-control" id="agency" placeholder="Requestor or Agency" />
</div>
<div class="form-group">
<label for="description">Description of Work:</label>
<input name="description" type="text" class="form-control" id="agency" placeholder="Description" />
</div>
<div class="form-group">
<label for="input-date">Enter Today Date</label>
<input name="input-date" type="date" value="">
<span class="result"></span>
</div>
<div class="form-group">
<div class="col-md-10">
<input id="submit" name="submit" type="submit" class="btn btn-primary">
</div>
</div>
</form>
该行是错误的,在该代码之前没有名为$POST的变量。您是否收到了成功消息,但数据库未得到更新或出现了全部错误 1检查双引号和单引号
<div class="form-group">
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
这是正确的还是错误的
三,
应该是
<label for="project_name">Project Name</label>
<input name="project_name" type="text"
这是一个语法错误,首先是echo$POST;它会给你一个未定义的$change通知,然后name = xxx’-复制/粘贴得到了你最好的。这是如果它甚至使它在大门外山姆@ JayBurgCARDIVE学习关于使用PDO的语句,并考虑使用。我收到一个错误,在第10行的C:\Program Files x86\Ampps\www\gisadmin\admin\insert.php中显示Send Notice:Undefined index:name in C:\Program Files x86\Ampps\www\gisadmin\admin\insert.php第11行的通知:Undefined index:project\u name in C:\Program Files x86\Ampps\www\gisadmin\admin\insert.php on第12行include../includes/config.php;你试过单引号和双引号解决问题吗?e、 是的,塔克斯卡拉帮我做了那部分。好的。。。项目名称谢谢你的剪报,它很有帮助。我没有意识到我把我的引语弄混了。但是,我仍然收到一个字段的错误通知:未定义索引:C:\Program Files x86\Ampps\www\gisadmin\admin\insert.php中的project\u name,在第10行如何找出导致此问题的原因?是的,检查编辑,您将以名称而不是project\u name发送输入。记住,输入的name属性将是$\u POST数组中的键。是的,我明白你的意思。谢谢,这非常有帮助,而且效果很好。
include("../includes/config.php");
<label for="project_name">Project Name</label>
<input name="name' type="text"
<label for="project_name">Project Name</label>
<input name="project_name" type="text"