Problem in Post method

Discussion in 'PHP' started by Shaimaa, Feb 11, 2010.

  1. #1
    Dear all,

    I have a problem in Post method

    the page go to the same page rather than going to another page

    here is the code of the 1st page:

    <?php
    
    // Get these from http://developers.facebook.com
    $api_key = 'xxxx';
    $secret  = 'xxxx';
    
    // Names and links
    //$app_name = "quiz_taker";
    //$app_url = "apps.facebook.com/quiz_taker/"; // Assumes application is at http://apps.facebook.com/app-url/
    //$invite_href = "quiz.php"; // Rename this as needed
    
    
    require_once ('../facebook-platform/php/facebook.php');
    
    $facebook = new Facebook($api_key, $secret);
    $facebook->require_frame();
    $user = $facebook->require_login();
    		
    $con = mysql_connect("localhost","mooledco_user","123456");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    // Create table
    mysql_select_db("mooledco_quiz", $con);
    $sql = "select * from question";
    
    $result = mysql_query($sql);
    // Execute query
    $i = 1;
    //echo'<fb:editor-custom >';
    echo '<form action="invite.php" method="post" id="quiz">';
    
    while($row = mysql_fetch_array($result))
      {
      echo $i.".".$row['description']."<br>";
    
      $select = "select description from Answer where question_ID=".$row['Q_ID'];
    
      $res = mysql_query($select);
    
      while ($r = mysql_fetch_array($res))
      {
    	echo "<input type='radio' name='answer".$i."' value='".$r['description']."' />";
    	
    	echo $r['description'];
    	echo "<br/>";
    	
      }
      echo "<br />";
      $i++;
      }
    
    echo '<input type="submit" value="Submit" />'; 
    echo "</form>";
    //echo '</fb:editor-custom>'; // end of echo
    
    mysql_close($con);
    
    ?>
    PHP:
    and Here's the code of the second page:

    <?php
    require_once ('../facebook-platform/php/facebook.php');
    
    $appapikey = 'xxxx';
    $appsecret = 'xxxx';
    // Connect to Facebook, retrieve user
    $facebook = new Facebook($appapikey, $appsecret);
    $user = $facebook->require_login();
    
    // Get a list of friends who are existing users of the app
    $app_users=$facebook->api_client->friends_getAppUsers();
    if ($app_users) {
    for ($i=0;$i<count($app_users); $i++ ) {
    if ($i != 0){
    $exclude_list .= ",";
    }
    $exclude_list .= $app_users[$i]["uid"];
    }
    }
    $ref_user = urlencode("&refuid=".$user);
    $invite_text = <<<FBML
    You’ve been invited to sign up with the grandest app in FacebookLand: F8 For
    Dummies!
    <fb:name uid="$user" firstnameonly="true"/> selfishly wants you to add F8 For
    Dummies! so that <fb:pronoun uid="$user"/> can get credit for it.
    118 Part II: Poking the API
    <fb:req-choice
    url="http://www.facebook.com/add.php?api_key=$appapikey&next=$ref_
    user"label="Sign up and become a Dummy!" />
    FBML;
    ?>
    <fb:request-form action="http://apps.facebook.com/dummies//index.php?c=skipped"
    method="POST" invite="true" type="Dummies"
    content="<?=htmlentities($invite_text)?>">
    <fb:multi-friend-selector showborder="false"actiontext="Invite your friends
    to use F8 For Dummies." exclude_ids="<?=$exclude_list?>" />
    </fb:request-form>
    PHP:
    What's the problem? I'm just using Facebook Library I think it's the problem?

    Thank You in advance
     
    Last edited: Feb 11, 2010
    Shaimaa, Feb 11, 2010 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    i used to program using facebook library.. as far as i remember using action="blah.php" will only send the post data.. they have dedicated functions to do redirection.
     
    bartolay13, Feb 11, 2010 IP