当我用来填充所有字段和数据时,数据没有在MySql数据库上更新,这里是PHP代码
<?php
include("dbconnect.php");
$name=$_POST['name'];
$phn=$_POST['phnno'];
$email=$_POST['email'];
$stuname=$_POST['stuname'];
$desc=$_POST['desc'];
if(empty($name)||empty($phn)||empty($stuname)||empty($email)||empty($desc)){
header("location:status.php?val=0");
die();
}
$sql="INSERT INTO feedback (name,phone,email,stuname,desc) VALUES ('$name','$phn','$email','$stuname','$desc')";
$result=mysqli_query($conn,$sql);
if(!$result){
header("location:status.php?val=1");
die();
}
header("location:status.php?val=2");
连接代码在
之下<?php
$conn = mysqli_connect('localhost', '********', '***********');
if (!$conn){
die("Database Connection Failed" . mysqli_error($conn));
}
$select_db = mysqli_select_db($conn, 'davkeonj_app');
if (!$select_db){
die("Database Selection Failed" . mysqli_error($conn));
}
请不要提及$ _POST安全问题或其他问题,我是 意识到他们。 重定向是成功的,但数据没有添加
<link href="https://fonts.googleapis.com/css?family=Oleo+Script:400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Teko:400,700" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">DAV PUBLIC SCHOOL</a>
</div>
<ul class="nav navbar-nav">
<li ><a href="http://davkeonjhar.org">Home</a></li>
<li><a href="http://davkeonjhar.org/admission">Admission</a></li>
<li><a href="http://davkeonjhar.org/contact-us">Contact</a></li>
<li class="active"><a href="#">Feedback</a></li>
</ul>
</div>
</nav>
<section id="contact">
<div class="section-content">
<h1 class="section-header">Feedback</h1>
</div>
<div class="contact-section">
<div class="container">
<form action="feedback.php" method="post">
<div class="col-md-6 form-line">
<div class="form-group">
<label for="exampleInputUsername">Your name</label>
<input type="text" class="form-control" name="name" placeholder=" Enter Name">
</div>
<div class="form-group">
<label for="exampleInputEmail">Email Address</label>
<input type="email" class="form-control" name="email" placeholder=" Enter Email id" required>
</div>
<div class="form-group">
<label for="telephone">Mobile No.</label>
<input type="tel" class="form-control" name="phnno" placeholder=" Enter 10-digit mobile no." required>
</div>
<div class="form-group">
<label for="Student Name">Student name</label>
<input type="tel" class="form-control" name="stuname" placeholder=" Enter student name" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for ="description"> Message</label>
<textarea class="form-control" name="desc" placeholder="Enter Your Message" required></textarea>
</div>
<div>
<button type="submit" class="btn btn-default submit" name="submit"><i class="fa fa-paper-plane" aria-hidden="true"></i> Send Message</button>
</div>
</div>
</form>
</div>
</section>
以上是页面的HTML代码