php - 如何让我的简单 php 表单转到我的 html 页面?
问题描述
我创建了一个简单的 PHP 代码,我希望它重定向到我的 HTML 页面,但我不知道该怎么做?有什么帮助吗?(顺便说一句,我不使用 MySQL)
I have attached the code below
https://jsfiddle.net/7ta2jyqv/
我只是希望它重定向到我创建的另一个页面,但我查看了教程,但没有一个有效
有人有我可以使用的简单代码吗?
解决方案
您好,您可以使用它:
<!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/
推荐阅读
- reactjs - 使用反应登录表单在 Spring Boot 中对用户进行身份验证
- android - 在 AccessibilityService 中获取 KEYCODE_HOME KeyEvent 需要什么 API 级别?
- java - 我在 windows 中使用 hadoop 时发生非法反射访问操作
- javascript - Break 语句未退出 JavaScript 中的所有嵌套循环
- visual-studio-2019 - 无法从 nuget 服务器找到 nuget 包
- api - Paypal Live API 泰国付款问题
- javascript - 他们在 Postgres 中查询日期的格式是什么?
- wpf - 使用 StackPanel 在用户定义的标题上修复 DataGrid 标题排序
- excel - 如何使用 .NET Core 中的 Syncfusion Xlsio 从 url 将图像添加到 XLSX 文件
- postgresql - Psql:使用 \copy from csv 导入日期列时出错