你好我近在我的表单编码包括验证和东西的完成,因为现在我们所有的时间都想阻止用户或垃圾邮件多次提交我们的表单。所以我想包括隐藏标记方法在我的剧本,但我不知道在什么地方代码我在我的特定php进程结构中,我的代码没有设置tokken?
unset($_SESSION['form_token']); or what i need in my process.php
让我form.php的开始:
<?php
session_start();
$form_token = uniqid();
$_SESSION['form_token'] = $form_token;
?>
和我隐藏tokken输入:
<input type="hidden" name="form_token" value="<?php echo $form_token; ?>" />
但我遇到麻烦的部分,我有我的表单中3个收音机submiting这里我的代码proces.php代码之后确定下一个页面:
<?php
require_once('formvalidator.php');
if(isset($_POST['form_btn'])) {
$validator = new simple_fv;
// fields info container
$fields = array();
// fill the container with fields data
$fields[] = array('index'=>'name', 'label'=>'Name', 'required'=>true, 'max_len'=>25);
$fields[] = array('index'=>'surname', 'label'=>'surname', 'required'=>true, 'max_len'=>30);
$indexes[] = array('index'=>'email', 'label'=>'E-mail', 'required'=>true, 'type'=>'email', 'max_len'=>200);
$fields[] = array('index'=>'phone', 'label'=>'phone number', 'min_len'=>4);
$fields[] = array('index'=>'country', 'label'=>'Country');
// get errors
$error = $validator->getErrors();
// if errors is not FALSE - print the succesfull message
if($error) {echo $error;}
else {if(isset($_POST['name']))
$emotion = $_POST['emotion'];
if($emotion == 'Basic Pack') {
session_start();
$_SESSION['form_token'] = true;
header('Location: /new/basicc.php');
} elseif($emotion == 'Deluxe Pack') {
header('Location: html6.php');
} elseif($emotion == 'Premium Pack') {
header('Location: html7.php');
}
这仅仅是一个缩短版的,但我不知道在什么地方编写unset($_SESSION['form_token']);
或
elseif($_POST['form_token'] != $_SESSION['form_token'])
{
$message = 'Access denied';
}
这样的想法是,用这个来防止用户提交表单回去后并填写所有领域应该这样他们将被定向到一个错误或form.php,但与干净的fieldset预先感谢
请问你可以更具体一些,因为我是一个开始在PHP哪里把什么,在此先感谢 – 2014-10-01 17:47:39