Jump to content

Get 'Name' out of the database


SanderVh

Recommended Posts

Hi there,

 

*little heads up: English isn't my native language, so excuse me for any mistakes in spelling etc.*

 

I've got a register/login script with activation mail, I secure my pages with this bit of code:

 

}

if (!$HTTP_SESSION_VARS["ingelogd"]) 
    {
        header("Location: login.php");
}

 

Because if someone logs in, the session is made:

 

// bekijk of de gegevens juist zijn
        if (mysql_num_rows($res) >= 1)
        {
            // registreer sessie (of cookie)
            $ingelogd = mysql_result($res, 0);
            session_register(ingelogd);
            // setcookie("ingelogd", "$ingelogd", time() + 1 * 86400);
            echo "<p style=\"font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #000000;\">
		U bent succesvol ingelogd.</p>";

            echo "<p style=\"font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #000000;\">
		Klik hier om <a href=\"home.php\">verder</a> te gaan.</p>";
                        
        }

 

My question: When someone registered, they entered their 'real' name, which is then placed into the database in the same row

as the username, password etc. I would like to state on the homepage which is secured 'Welcome 'Name'!' I do I get this 'Name' value

out of the database and into my page?

 

Thanks in advance!

 

Sander

Link to comment
https://forums.phpfreaks.com/topic/230333-get-name-out-of-the-database/
Share on other sites

Thanks for the help so far, I've put this at the top of the page with the security check:

 

$row = mysql_fetch_assoc($ingelogd);

 

And this in my text:

 

<?php echo $row['surename'];>

 

Surename is the name of the column, however, I get this error message at the top of the page:

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/dainformat/domains/informaticaweb.nl/public_html/idee/Sander/home.php on line 19

 

What did I do wrong?

Thanks in advance  ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.