0

我正在尝试使用 Facebook 登录创建登录。当我创建它时,它转到 fb 登录面,然后它不重定向。它不创建页簿会话变量。这是什么原因。我用谷歌搜索,但找不到任何答案。请有人帮助我。这是我的代码

<?php

require 'src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
 'appId' => '435154566546556',
 'secret' => 'f6ff918559a2061ebadd881ee59f2702',
));

  // Get User ID
$user = $facebook->getUser();

if ($user) {
 try {
  // Proceed knowing you have a logged in user who's authenticated.
   $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
  error_log($e);
  $user = null;
 }
}

 // Login or logout url will be needed depending on current user state.
   if ($user) {
 $logoutUrl = $facebook->getLogoutUrl(array(
                    'next' => 'http://localhost/ronyar/logout.php'));
 } else {
 $loginUrl = $facebook->getLoginUrl();
}


 ?>
  <?php

   if($_SESSION['fb_495235147162870_user_id'])
     {
   $_SESSION['email'] = $user_profile['email'];
   $_SESSION['user_id'] = $_SESSION['fb_495235147162870_user_id'];
   header('Location:songs.php');

    }
     ?>       
<html>
<head>

  <title>Ronyar</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-   1.0a1.min.css" />
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
<script>

  function submit1(){

  window.location.href ='sign_up.php';


  }

</script>   
<style>
.ui-page { background: #242424;}   
</style>   

<body  >
<div data-role="page" data-theme="a">

        <header data-role="header" >   
        <img src="images/loginform.jpg" width="100%" />  
       </header>






     <div data-role="content"  >





           <form id='myform' name='myform' action='signin_validation.php' method='post'>
            E-mail :
            <input type="text" name="email" name="email"/> <br/>
            Password :
            <input type="password" name="pw" name="pw"/> <br/>

            <input type="submit" name="submit" value="Login" data-theme="a"/>
             <br/>
           <p style="background-color:#000000"> <hr/></p>
           <br/>

        </form>


          <form id='myform1' name='myform1' action='<?php echo $loginUrl; ?>' method='post'>


            <input type="submit" name="submit1" value="Login With Facebook" data-theme="b"/>

        </form>

        <br/>
    <a href="" style="text-decoration:none; color:#993333; background-color:#CCCCCC; float:none" onclick="submit1()"  ><img src="images/signup.jpg" width="100%"/></a> 






</div><!-- /content -->

<div data-role="footer" data-theme="a">
    <p align="center" style="color:#168797;">Copyright  2012&copy;www.ronyar.com <br/> All Rights Reserved.</p>
</div><!-- /header -->

4

1 回答 1

0

尝试关闭 AJAX

<form id='myform1' name='myform1' action='<?php echo $loginUrl; ?>' method='post' data-ajax="false">
于 2013-02-25T20:36:37.710 回答