Forum Moderators: coopster
The current code which redirects the user is a follows:
// Register the values & redirect:
$_SESSION = mysqli_fetch_array ($r, MYSQLI_ASSOC);
mysqli_free_result($r);
mysqli_close($dbc);
// Define the URL:
$url = BASE_URL . 'login/memberarea.php'; // Define the URL:ob_end_clean(); // Delete the buffer.
header("Location: $url");
exit(); // Quit the script.
Thanks guys
[edited by: eelixduppy at 7:07 pm (utc) on Aug. 26, 2008]
[edit reason] disabled smileys [/edit]
So you can have:
<h1>Hello <?php echo $_SESSION['name'];?></h1>
<p>Some more customized stuff</p>
That way you dont need to worry about having to add a new page for each new member. It is customized to each member from the information that you hold about them in your database and are storing in your SESSION.
Is their a way of creating links due to the different users. i could create another column in the table in the database called 'page' which has the users homepage , for example user14.php how would i then put this on the memberarea.php page?
Thanks very much for your help
Tom
I.E. One page, memberarea.php, which is passed a user ID, so it looks like this: [someurl.com...] Then you use that ID to go into the database, grab the users info, and populate the page with it. That way you're not creating a bunch of excess files.
Although if you want to do it your way, you could store all of the HTML in the database, and then simply echo it, or save the actual PHP file, and use include to add the user php file to memberarea.php.
Also i have used the example you gave me and done this.
<h1 class="style29">Welcome <?php echo $_SESSION['first_name'] ;?></h1>
<p class="style29">Please find your pictures on the website. We haven't changed or edited of the pictures. You can share all your pictures with friends buy simply logging onto the website. Please do not share your username and password with others. This is to protect the security of your pictures. </p>
<h1 class="style29">To access your pictures please click the link here <?php echo $_SESSION['page'] ;?></h1>
The only thing is that the second php code will not come up on the page
can you help?
If you want to see what is contained within the $_SESSION array you can use
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
var_dump($_SESSION);
[edited by: dreamcatcher at 6:22 pm (utc) on Aug. 27, 2008]
[edit reason] use example.com. Thanks. [/edit]
members.php?id=123
then, in the members.php page, you can display results based on the id
$id = $_GET['id'];
$user = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE id = '$id'");
if ($id!=$_SESSION['id']){
header("location: bad.php");
}
else
{
your stuff here..
}
now if a user tries to change it, it wont work :)
$userinfo = mysql_fetch_object(mysql_query("SELECT * FROM users where username = '$username' and password = '$password'"));
$_SESSION['id'] = $userinfo->id;
and to correct a code up top
$user = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE id = '$id'");
with
$user = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE id = '$id'"));