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 :)

Recommended Answers

All 3 Replies

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';
    }
}

?>

Correction:

$result = mysql_query($queryGet);

Thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.