I am building a music community website, been working on it for over a month, I am now stuck.
The registration works fine, everything gets written to the database, including the id info, which is what I am having problems with.
I am using a flash header to login, the flash movie also uses a php script to detect wether or not u are logged in, if not it displays email and password fields, if u are logged in, it displays three buttons, view, edit, and logout, now here is where I am having problems, when I log in, go to the profile.php page, there is nothing, none of the info written to the database is showing up, it does show up if I manually put the id number into the page, but not through the php scripting, a couple of guys and myself have been trying to debug it over at sitepoint, but all we could figure out is that it is not grabbing and implementing the id properly, so I put in some code to show me where the id comes from and where it becomes invalid, and this is what it output:
id from SESSION:
id after ` filter: 0
Invalid member
now obviously this means that the session was never even started properly, so here is my php code for the profile.php page, I am omitting the html since that (as of yet) is not causing a problem.
<?php
session_start();
include_once "scripts/connect_to_mysql.php";
$id = "";
$username = "";
$firstname = "";
$lastname = "";
$country = "";
$state = "";
$city = "";
$zip = "";
$bio_body = "";
$bio_body = "";
$website = "";
$youtube = "";
$user_pic = "";
$blabberDisplayList = "";
if (isset($_GET['id'])) {
echo "id from GET: " . $_GET['id'] . "<br>"; //debug
$id = (int) $_GET['id'];
} else if (isset($_SESSION['id'])) {
echo "id from SESSION: " . $_SESSION['id'] . "<br>"; //debug
$id = (int) $_SESSION['id'];
} else {
include_once "index.php";
exit();
}
$id = str_replace('`', '', $id);
echo "id after ` filter: $id<br>"; //debug
$id = (int)$id;
if( $id == 0 ) {
exit('Invalid member');
}
$sql = mysql_query("SELECT * FROM myMembers WHERE id=$id");
while($row = mysql_fetch_array($sql)){
$username = $row["username"];
$firstname = $row["firstname"];
$lastname = $row["lastname"];
$country = $row["country"];
$state = $row["state"];
$city = $row["city"];
$zip = $row["zip"];
$email = $row["email"];
//$email = "<a href=\"mailto:$email\"><u><font color=\"#006600\">Mail</font></u></a>";
$sign_up_date = $row["sign_up_date"];
$sign_up_date = strftime("%b %d, %Y", strtotime($sign_up_date));
$last_log_date = $row["last_log_date"];
$last_log_date = strftime("%b %d, %Y", strtotime($last_log_date));
$bio_body = $row["bio_body"];
$website = $row["website"];
$youtube = $row["youtube"];
$check_pic = "members/$id/image01.jpg";
$default_pic = "members/0/image01.jpg";
if (file_exists($check_pic)) {
$user_pic = "<img src=\"$check_pic\" width=\"300px\" />";
} else {
$user_pic = "<img src=\"$default_pic\" width=\"300px\" />";
}
if ($youtube == "") {
$youtubeChannel = "<br />This user has no YouTube channel yet.";
} else {
$youtubeChannel = ' <script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/youtube.xml&up_channel=' . $youtube . '&synd=open&w=290&h=370&title=&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script> ';
}
}
$style_sheet = "default";
?>