I am working on a facebook application which uses FBML(Facebook Markup Language)
This is code for a page that allows a user to select all of their trips, and invite friends that are also going on the trip. In the 'content' attribute of the fb:request form I have included $trip_id as a variable. However my problem lies in the fact that the value is not passed to the 'content' string after submitting the form. The values are in the select item. The value is passed to the server but the 'content' url never recieves the value. How can I make this work. I am very new to PHP and have been banging my head on the keyboard for a while.
if (isset($_POST['submitted'])){
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
$trip_id = $_POST['trip'];
$invited_ids = $_POST['ids'];
if (get_magic_quotes_gpc())
{
// If magic quotes is enabled - turn the string back into an unsafe string
$trip_id = stripslashes(trim($trip_id));
}
// Now convert the unsafe string into a MySQL safe string
//$trip_id= mysql_real_escape_string($variable);
$query = "INSERT INTO bp_guests (trip_id,user_id) VALUES ";
for($i = 0, $c = count($invited_ids); $i < $c; $i += 1) {
// Add the next batch of values to the query string
$query .= "($trip_id, $invited_ids[$i])";
// Add a comma is this is not the last batch
if($i + 1 < $c) {
$query .= ", ";
}
}
//echo $query;
$result = mysql_query($query);
$checkPost = true;
}
$query1 = "SELECT first_name FROM user WHERE uid=$user_id";
$result1 = $facebook->api_client->fql_query($query1);
$firstname = $result1[0]['first_name'];
$query2 = "SELECT last_name FROM user WHERE uid=$user_id";
$result2 = $facebook->api_client->fql_query($query2);
$lastname = $result2[0]['last_name'];
if(checkPost){
echo "\n \n \n Your guests have been notified. Thank you for using Block Party. Please invite all other guests below. \n";
}
<fb:fbml>
<fb:request-form
action="guests.php"
method="POST"
invite="true"
type="Block Party"
content="You have been selected as a guest of <?php echo $firstname ." "; echo $lastname; ?>.<?php echo htmlentities("<fb:req-choice url=\"http://apps.facebook.com/block-party/guest_registration.php?trip_id=$trip_id\" label=\"Confirm Trip Attendance\""); ?>">
<!------------------------------->
<table border="0" id="myTable">
<tr>
<td>Planned Trip</td>
<td>
<select name="trip">
<?php
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
$query = "SELECT trip_id,group_type,dest,date_format(check_in,'%b/%e/%Y') as displayDate FROM blockparty WHERE user_id=$user_id";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo '<option name=\"trip\" value='.$row['trip_id'].'> '.$row['group_type'].''." - ".''.$row['dest'].''.", ".''.$row['displayDate'].' ';
}
?>
</select>
</td>
</tr>
</table><br />
<input type="hidden" name="submitted" value="TRUE" />
<!------------------------------->
<fb:multi-friend-selector showborder="false" actiontext="Invite your friends to your trip!" bypass="cancel">
</fb:request-form>
</fb:fbml>