我已经按照我在教程中看到的内容为我的新站点编写了一个简单的 php 文件。不幸的是,当我在我的本地主机上发布网站时,提交按钮没有出现在页面中。你能帮帮我吗?
代码如下:
//new_entry.php
<?php
$con=mysqli_connect("localhost","root","","youtube");
?>
if(isset($POST['submit'])){
echo $str=$POST['str'];
}
<form method="post">
<input type="textbox" name="str" required/>
<input type="submit" name="submit" value="Search"/>
</form>
//索引.php
<?php
define ("SITE_ADDR", "http://localhost/CharleroiFurniture");
$site_title = "CharleroiFurniture" ;
?>
<html>
<head>
<meta charset="wtf-8>
<meta name="viewport" content="width-device-width">
<title><?php echo $site_title; ?> </title>
<link ref="stylesheart" type="text/css" href="./main.css"></link>
</head>
<body>
<div fd="wrapper">
<div fd="tmp_header">
<div fd="nav">
<a href="<?php echo SITE_ADDR;?>/new_entry.php" New Entry</a>
</div>
<div fd="logo">
<hI><a href="<?php echo SITE_ADDR;?>">CharleroiFurniture/a></hI>
</div>
</div>
<div fd="main" class="shadow-box" >
<div fd="content">
<form action="" method="GET" name="">
<table>
<tr>
<td><input type="text" name="k"></td>
</tr>
</table>
</form>
</div>
</div>
<div fd="footer"></div>
</div>
</body>
</html>
目标是在制作提交表单时生成提交按钮或任何其他按钮
所以看起来你有 2 页。 index.php 具有表单,而 new_entry.php 是表单处理程序。您需要进行一些更改才能使其正常工作。
index.php
<form action="new_entry.php" method="POST">
<input type="text" name="str">
<input type="submit" value="submit">
</form>
new_entry.php
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo $_POST['str'];
}
<form action="new_entry.php" method="POST">
<input type="text" name="str">
<input type="submit" value="submit">
</form>