PHP and MYSQL Help | FerrariChat

PHP and MYSQL Help

Discussion in 'Technology' started by 4REphotographer, Apr 15, 2010.

This site may earn a commission from merchant affiliate links, including eBay, Amazon, Skimlinks, and others.

  1. 4REphotographer

    4REphotographer F1 Veteran

    Oct 22, 2006
    6,197
    Arlington, VA
    Full Name:
    Chris
    Trying to put together a client log-in for my website and I'm having difficulty redirecting users to their specific page. I have it so all users are redirected to a page, but I want it so that they are redirected to a page based on their own username.

    I've tried to learn some code in the past, but I'm just not that proficient with it. If anyone could help me out via pm or email I'd really appreciate it.
     
  2. cozmogeek

    cozmogeek Rookie

    Mar 12, 2009
    12
    Bellevue WA
    Did you ever figure this out?
     
  3. DevonL

    DevonL Formula 3

    Mar 13, 2010
    2,442
    NYC
    Full Name:
    Devon
    This should give you a good start on what you're looking to do.
    PHP:
    <?php 
    include 'config.php';

    $user mysql_real_escape_string($_POST['user']);

    if (
    $_POST['Submit']=='Login')
    {
    $md5pass md5($_POST['pwd']);
    $sql "SELECT id,user FROM users WHERE 
                user = '
    $user' AND 
                pwd = '
    $md5pass' AND activated='1'"
                
    $result mysql_query($sql) or die (mysql_error()); 
    $num mysql_num_rows($result);

        if ( 
    $num != ) { 

            
    // A matching row was found - the user is authenticated. 
           
    session_start(); 
           list(
    $user_id,$user) = mysql_fetch_row($result);
            
    // this sets variables in the session 
            
    $_SESSION['user']= $user;  
            
                
            if (isset(
    $_GET['ret']) && !empty($_GET['ret']))
            {
            
    header("Location: $_GET[ret]");
            } else
            {
            
    header("Location: myaccount.php");
            }
            
    //echo "Logged in...";
            
    exit();
        } 

    header("Location: login.php?msg=Invalid Login");
    //echo "Error:";
    exit();        
    }

    ?>
     

Share This Page