是否可以通过使用PHP将用户重定向到不同的页面?
假设用户去了www.example.com/page.php,我想将它们重定向到www.example.com/index.php,如何在不使用元刷新的情况下这样做?可能吗?
这甚至可以保护我的页面免受未经授权的用户
我有一个简单的表单,将文本提交到我的SQL表.问题是,在用户提交文本后,他们可以刷新页面并再次提交数据,而无需再次填写表单.我可以在提交文本后将用户重定向到另一个页面,但我希望用户保持在同一页面上.
我记得读过一些关于为每个用户提供一个唯一的会话ID并将其与另一个值进行比较的方法,这个值解决了我遇到的问题,但我忘记了它的位置.
我有一个简单的PHP邮件程序脚本,它从通过POST提交的表单中获取值并将它们发送给我:
<?php
$to = "me@example.com";
$name = $_POST['name'];
$message = $_POST['message'];
$email = $_POST['email'];
$body = "Person $name submitted a message: $message";
$subject = "A message has been submitted";
$headers = 'From: ' . $email;
mail($to, $subject, $body, $headers);
header("Location: http://example.com/thanks");
?>
Run Code Online (Sandbox Code Playgroud)
我该如何消毒输入?
我有以下表格供用户填写:
<form name="form" action="" method="POST">
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="25%" ><div align="right"><strong>Name:</strong></div></td>
<td width="75%" ><span id="sprytextfield1">
<input id="Cname"name="Name" type="text" placeholder="Please fill in your name">
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td><div align="right"><strong>Email:</strong></div></td>
<td><span id="sprytextfield2">
<input id="Cemail"name="email" type="text" placeholder="e.g sales@company.co.uk">
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td><div align="right"><strong>Phone Number:</strong></div></td>
<td>
<input id="Cphone" name="Phone" type="text"placeholder="e.g. 5555-6666666">
</td>
</tr>
<tr>
<td> </td>
<td><input name="Manufacturer" type="hidden" value="<?php echo $row_emailProduct['Manufacturer']; ?>">
<input name="Model" type="hidden" value="<?php echo $row_emailProduct['Model']; ?>">
<input …Run Code Online (Sandbox Code Playgroud)