如何使我的简单php表单进入我的html页面



我创建了一个简单的PHP代码,我想让它重定向到我的HTML页面,但我不知道如何做到这一点?有什么帮助吗?(我不使用MySQL btw(

I have attached the code below
https://jsfiddle.net/7ta2jyqv/

我只是想把它重定向到我创建的另一个页面,但我看了教程,它们都不起作用

有人有我可以使用的简单代码吗??

试试我的代码,它非常简单,首先你要创建一个名为index.php的文件并在下面的代码

<?php
if(isset($_GET["button"])){
header("Location:redirect.html");
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="GET">
<button type="submit" name="button">Click to redirect!</button> 
</form>
</body>
</html>

之后,您将创建一个名为redirect.html的文件低于代码

<!DOCTYPE html>
<html>
<head>
<title>Redirected</title>
</head>
<body>
<h1>Your page finish to redirect ^_^</h1>
</body>
</html>

在浏览器中打开index.phphttp://localhost/yourFolder/index.php

然后生成像这样的图像

然后只要点击按钮,你就会被重定向。

你好,你可以使用它:

<!DOCTYPE html>
<html>
<head>
<title>Redirect Form To a Particular Page On Submit - Demo Preview</title>
<meta content="noindex, nofollow" name="robots">
<link href='css/redirect_form.css' rel='stylesheet' type='text/css'> <!--== Include CSS File Here ==-->
</head>
<body>
<div class="main">
<div class="first">
<h2>Redirect Form To a Particular Page On Submit using PHP</h2>
<form action="redirect_form.php" id="#form" method="post" name="#form">
<label>Name :</label>
<input id="name" name="name" placeholder='Your Name' type='text'>
<label>Email :</label>
<input id="email" name="email" placeholder='Valid Email Address' type='text'>
<label>Contact :</label>
<input id="contact" name="contact" placeholder='Contact' type='text'>
<label>Address:</label>
<input id="address" name="address" placeholder='Address' type='text' value="">
<input id='btn' name="submit" type='submit' value='Submit'>
<!---- Including PHP File Here ---->
<?php
include "include/redirect.php";
?>
</form>
</div>
</div>
</body>
</html>

在php中提交表单使用它:

<?php
if(isset($_POST['submit'])){
// Fetching variables of the form which travels in URL
$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$address = $_POST['address'];
if($name !=''&& $email !=''&& $contact !=''&& $address !='')
{
//  To redirect form on a particular page
header("Location:https://www.formget.com/app/");
}
else{
?><span><?php echo "Please fill all fields.....!!!!!!!!!!!!";?></span> <?php
}
}
?>

记住,这只是一个例子。header函数有助于php中的重定向。检查此链接:https://www.formget.com/how-to-redirect-a-url-php-form/

最新更新