我正在尝试创建一个表单,将表单中的信息发布到数据库中。但我的编码不起作用!愿有人请帮帮我吗?这是代码:
这是refund.php
文件,格式为:
<?php
include "../autoload.php";
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" class="ui" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="../assets/css/main5.css" media="screen">
<meta charset="utf-8">
<title>Refund site</title>
</head>
<body>
<div class="admin-panel">
<div class="content">
<h1>Refund</h1>
<br>
<a href="index.php">Back</a>
<br>
<form class="refund" action="insert.php" method="post">
<i class="fa fa-user" aria-hidden="true"></i><input type="text" name="username" value="" placeholder="Username"><br><br>
<i class="fa fa-list" aria-hidden="true"></i><input type="email" name="email" value="" placeholder="email"><br><br>
<i class="fa fa-list" aria-hidden="true"></i><input type="text" name="kontonummer" value="" placeholder="phone"><br><br>
<button type="submit" name="post_news">Send</button>
</form>
</div>
</div>
</body>
</html>
这是执行发生的insert.php
文件:
<?php
include "../autoload.php";
if (isset($_POST['refund'])) {
$username = $_POST['username'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$refund = new refund();
$refund->post_news($username, $email, $phone);
}
?>
有人可以帮我解决错误吗? 需要帮助快速!
问候,亨利
答案 0 :(得分:1)
你的问题不足以发现问题,这是快速回答
你在哪里用HTML设置$ _POST ['退款']?
if (isset($_POST['refund'])) {
你可以添加
<input type="hidden" name="refund" value="anything">
并且$ _POST ['手机']似乎没有正确设置
<input type="text" name="kontonummer" value="" placeholder="phone">
不符合
$phone = $_POST['phone'];
答案 1 :(得分:0)
实际上你的错误就在这里$ _POST ['退款'],实际上在你的表单中找不到...更改下面的代码如下if (isset($_POST['post_news'])) {