0

Didnt know where to post this question mysql or here, since im working with php i decided to put it here..
Im starting to learn mysql now :)
SO i just wanna retrive a full name from a user how would i do this?
im imaging this should be done at login ? so

if ($username && $password) {
$queryGet = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
$numRows = mysql_num_rows($queryGet);


    if ($numRows != 0) {

     //i want to put a variable session like what i did below 
     //with username but with a value thats inside mysql called 'full_name' 

     $_SESSION['username'] = $username_LI;

     echo 'You have logged in correctly';

    }

Very thanks :)

2
Contributors
3
Replies
9
Views
3 Years
Discussion Span
Last Post by centenond
1

Try this:

<?php
//You need this first
session_start();

if ($username && $password) 
{

    $queryGet = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
//    $numRows = mysql_num_rows($queryGet); dont need this
    $result = mysql_query($sql);
    if ($result) 
    {
        while($row = mysql_fetch_array($result))
        {
            $_SESSION['username'] = $row['full_name'];    
        }  
    echo 'You have logged in correctly';
    }
}

?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.