脚本宝典收集整理的这篇文章主要介绍了通过单击更改php会话值,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图这样做,但它不起作用:
<?PHP session_start(); $_SESSION['role']="";?> <!DOCTYPE htML> <html XMlns="http://www.w3.org/1999/xhtml"> <head> <tITle></title> <link href="auth-buttons.css" rel="stylesheet" /> <link href="StyleSheet.css" rel="stylesheet" /> </head> <body> <div id="wrap"> <div id="wrapHome"> <p><a class="BTn-auth btn-faceBook large" href="redirect.PHP" onclick="<?PHP $_SESSION['role']="facebook" ?>" > Sign in with <b>Facebook</b> </a></p> <p><a class="btn-auth btn-twitter large" href="redirect.PHP" onclick="<?PHP $_SESSION['role']="twitter" ?>" > Sign in with <b>Twitter</b> </a></p> <p><a class="btn-auth btn-GOOGLE large" href="redirect.PHP" onclick="<?PHP $_SESSION['role']="google" ?>" > Sign in with <b>Google</b> </a></p> </div> </div> </body> </html>
#('.btn-auth btn-facebook large').click(function(){ // fire off the request to /redirect.PHP request = $.ajax({ url: "/redirect.PHP",type: "post",data: 'facebook' }); // callback handler that will be called on success request.done(function (response,textstatus,jqXHR){ // LOG a message to the console console.log("Hooray,it worked!"); }); // callback handler that will be called on failure request.fail(function (jqXHR,errorThrown){ // log the error to the console console.error( "The following error occured: "+ textStatus,errorThrown ); }); });
在你的redirect.PHP中
<?PHP $_SESSION['role'] = $_POST['data']; ?>
以上是脚本宝典为你收集整理的通过单击更改php会话值全部内容,希望文章能够帮你解决通过单击更改php会话值所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。