开发者

How can I create a button that links to another PHP page and still staying inside Facebook framework?

I am new both to PHP and new to Facebook...

I am trying to create a button that开发者_C百科 by clicking on it, the next page will be called ,

how can I do that and still remain in Facebook framework?

I tried using an HTML button with reference to next PHP page, but it took me out of Facebook framework...

and I need to use variables from the calling page.

can someone help me?

Thank!!


In PHP, you should always use a "Dispatcher" in your top level directory, and hide your other classes in subfolders, with appropriate permissions.

Doing so, here is what you can do:

index.php (dispatcher)

<?php
switch($_GET['p']) {
 case 'home':
    include './include/home.php';
    break;
 case 'anotherPage':
    include './include/anotherPage.php';
    break;
 default:
   include './include/home.php'; 
   break;
}
?>

And now, all you have to do is to call your Facebook page like this (sorry, I don't remember the exact facebook url for application):

http://www.facebook.com/yourapp/?p=home
http://www.facebook.com/yourapp/?p=anotherPage

[EDIT] If you want to send informations and get it back, modify your HTML form to POST data at the dispatcher like this:

<FORM METHOD=POST ACTION="./?p=anotherPage">

Than, modify the "anotherPage.php" to verify the POST data, process it and maybe set the data you want back in $_SESSION['myVariable']. Once everything is done, redirect the page to the initial one:

<?php
session_start();
if (ISSET($_POST['myData']) && $_POST['myData'] == 1) {
    $_SESSION['myVariable'] = "HelloWorld";
}
header('Location: http://www.facebook.com/myApp/?p=home');

I hope this will help you with your project

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜