我正在寻找一些在我的代码中导致这个PHP页面不重定向的错误。我正在查看是否有人可能知道这个问题的原因(这可能与Cookie有关)。PHP脚本不通过标头重定向
inc_vars.php:
<?php
//some of the variables have been omitted.
$pid = 'gbb';
$dbtable ='';
$dbname = '';
$dbuser = '';
$dbpass = '';
$connect = mysql_connect('localhost', $dbuser, $dbpass);
if(!$connect){
header('Location: omitted');
die();
}
mysql_select_db ($dbname, $connect);
$webroot = 'omitted';
$share_page = $webroot . '/share-the-training';
$gift = $webroot . '/free-video?setuser=1199';
$bonus_content = $webroot . '/awesome-bonus';
$share_php = $webroot . '/share.php';
?>
refresh_id.php:
<?php
include_once('inc_vars.php');
$results = mysql_query("SELECT id FROM " . $dbtable . " WHERE email='" . $_GET['email'] . "'");
if(!$results || mysql_num_rows($results)==0){
header('Location: ' . $share_page . '?errorcode=1');
die();
}
$res_arr = mysql_fetch_assoc ($results);
setcookie($pid . "_viral", (string)$res_arr['id'], time() + 3600 * 365);
move_on();
function move_on(){
header ('Location: ' . $share_php);
die();
}
?>
当人参观refresh_id.php电子邮件= their_email他们应该重定向到$ share_php页面。这不起作用。
但是,如果发生这种情况:refresh_id.php?email = an-email-that-is-in-in-database那么脚本重定向到$ share_page绝对没问题。
我已经尝试了这种方法,并且没有使用gbb_viral cookie。我不知道为什么这不起作用。所有网页现在都可以在网上直播,以防万一你想要寻找自己。
省略
存在于数据库如下电子邮件:[email protected](对于那些要测试的这款)
更新范围
愚蠢的错误。我只是在move_on()函数中添加了全局$ share_php,现在一切正常。感谢大家对SQL注入的关注,我现在正在切换到准备好的语句。
注意SQL注入攻击 - 您正在将GET VAR直接转储到您的查询中。使用预准备的语句 – Utkanos 2012-07-29 18:41:19