我希望有人可以帮助我。
我有3个页面,一个注册页面,其中包含在iframe中加载我的第二页的调用,这是一个发布到第三页的表单,用于处理注册。
我要做的是在用户注册后设置会话变量,并将其传递回初始注册页面。
我遇到的问题是,当第三页关闭时,第一页上的后续关闭不会被解雇?
RegisterPage.php
<script type="text/javascript">
function fancyboxTest(href,provider,providerid,username,email,location,firstname,surname) {
$.fancybox({
padding: 0,
autoResize: true,
autoSize: true,
closeBtn:false,
closeClick:false,
afterClose : function() {
location.href = "home.php?se=<?php session['login'];?>";
},
modal:true,
type: 'iframe',
'href' : href + '?provider='+escape(provider)+'&providerid='+escape(providerid)+'&username='+escape(username)+'&email='+escape(email)+'&location='+escape(location)+'&firstname='+escape(firstname)+'&surname='+escape(surname)+''
});
}
</script>
第三页
<?php
$_Session_start();
$provider = $_POST['provider'];
$providerID = $_POST['providerid'];
$username = $_POST['user_name'];
$email = $_POST['user_email'];
$forenames = $_POST['user_forename'];
$surname = $_POST['user_surname'];
$location = $_POST['user_location'];
$date = date('Y-m-d H:i:s');
$database = new Database();
$database->query('INSERT INTO users(provider, provider_id, name_forename, name_surname, name_username,registered_date) VALUES (:provider, :provider_id, :forename, :surname, :username,:datereg)');
$database->bind(':provider', $provider);
$database->bind(':provider_id', $providerID);
$database->bind(':forename', $forenames);
$database->bind(':surname', $surname);
$database->bind(':username', $username);
$database->bind(':datereg', $date);
$database->execute();
$nid = $database->lastInsertId();
$database = new Database();
$database->query('INSERT INTO profile(id, location, email) VALUES (:id, :location, :email)');
$database->bind(':id', $nid);
$database->bind(':location', $location);
$database->bind(':email', $email);
$database->execute();
$tses = sha1($providerID . $date);
$_session['login'] = $tses;
$database = new database();
$database->query('UPDATE users SET session_id = :session WHERE id = :id');
$database->bind(':session', $_session['login']);
$database->bind(':id', $nid);
$database->execute();
?>
<script type="text/javascript">
parent.$.fancybox.close();
</script>
关于最新情况的任何想法?用户已成功注册并且iframe关闭,但浏览器位于注册页面?我已经尝试重定向到home.php而没有任何参数,因为我不确定会话是否已设置,如果我在注册页面上包含session_start,我会收到警告它已经启动。
答案 0 :(得分:0)
知道了!
从形式3开始,这就是诀窍
<script type="text/javascript">
parent.jQuery.fancybox.close();
window.parent.location.href = 'home.php?se=<?php echo $tses;?>';
</script>