我有一个表格,当我将它张贴我创建了一个cookie,那么我读取cookie,如果isset然后做一些事情:PHP,回声不显示后的形式发布?
内read.php
<?php if (isset($_COOKIE['voteforme'])) {
echo 'You voted this profile';
} else {?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="vote_points" id="vote_points" value="1000" />
<input type="submit" name="votes_send" id="votes_send" value="Vote for me" />
</form>
<?php } ?>
然后我里面做一些cookie创建“创建.PHP“:
if (isset($_POST['votes_send'])){
$get_vote_for_me = $_POST['vote_points'];
$get_talent_id = $_POST['talent_id'];
$value1 = "voteforme";
$value2 = "voteforme_points";
setcookie($value1,$value2, time()+3600*24*7);
}
此脚本创建的cookie,我需要。基本上如果cookie设置为$_COOKIE['voteforme']
则显示一条消息,否则显示该表单。
我的问题是我需要刷新页面第二次页面读取cookie并查看是否存在与否。
文件结构是index.php
其中i包括read.php
和 'create.php'
任何想法?
感谢
编辑: 即使我设置表单动作为所有这些文件的结果是一样的
编辑,index.php
结构:
<?php
require_once("read.php");
include 'create.php';
?>
<!doctype html>
<head>...
<body>...
<div id="tab5" class="tab_content">
<?php read();?> // the read.php it's a function
</div>
...
的read.php
我很需要它它在顶部,但我实际上并没有调用git,直到在身体内部作为函数
横坑: 我也尝试添加setcookie
的else
语句中的“read.php”里面,但是它并没有生成
这是我设置它的方式。 'create.php'文件是第一个内联 – Patrioticcow
你可以建立你的index.php文件的准系统结构,然后我可以更清楚地看到发生了什么。 –
请看我编辑的帖子 – Patrioticcow