SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    0 Post(s)
    0 Thread(s)

    A little help with PHP/MySQL

    Hey there guys!
    I'm building up a site for a friend, he's a lawyer, and he just needs basic info such as street address, staff, some pictures, about us, contact us, know, the basic, static stuff I can do with simple but well designed HTML, and I got no problem there (I'm doing this with Dreamweaver CS3).
    However, here comes the tricky part:
    He wants his clients to be able to log in with a username/password and check their cases on the website, which means I would need to create a different unique page for each user.

    So, being a complete newbie with PHP and MySQL, I successfully followed a tutorial on how to create a login page for users...I can't post the URL to such tutorial since I'm new, but it covered the basics of creating a new database, connecting to such database, embedding it to my login form, trying it out, etc. Everything was understood. Everything went fine. That's covered.

    Now, all I need, is to know how to redirect each user to his own page, where he'll be able to find his documents, cases, pictures, or whatever my friend asks me to upload. And I don't know how to pull off that kind of code PHP-wise. I don't even know how it is called (what I'm trying to do). Is it related to sessions or cookies?

    For example, Mr. Jones wants to check how his car insurance case is going, so he would go to the website, login, and he would be redirected to a page that only HE can see. This page will contain pictures of his crashed car, text files, or whatever I upload...

    I hope you can understand what I'm trying to do It's like when you go to your profile page here in the forum.

    I'm sure it's not too hard for experienced users to accomplish something like this. If you could tell me how to achieve this I'd be really grateful!

    Thanks a lot!

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Lancaster University, UK
    2 Post(s)
    0 Thread(s)
    Simple but well designed HTML [...] I'm doing this with Dreamweaver CS3.
    I do hope you're not doing it in Design View then, and you're hand-coding the HTML and CSS yourself. Otherwise the former half of this quote is contradictory to the latter.

    If you're using $_SESSIONs for the login process (which would be the best approach by far) you could do something like this:
    PHP Code:
    header('Location: User/Home.php'); //redirection
    exit; //So the rest of the page isn't processed 
    The Home.php would look like:
    PHP Code:
    array_key_exists('User'$_SESSION) || $_SESSION['User']['LoggedIn'] == false){
    header('Location: Login.php');
    //Note that this stops the rest of the page processing, so there is no need to do an else{}
    $Username $_SESSION['User']['Username'];
    "<h3>Welcome to your page, {$Username}</h3>";
    That's how they can get their own page. However, getting more information such as cases etc would be harder.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts