SanderVh Posted March 11, 2011 Share Posted March 11, 2011 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 Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted March 11, 2011 Share Posted March 11, 2011 You need to fetch the data from the query result: $row = mysql_fetch_assoc($ingelogd); echo $row['Name']; The mysql_fetch_assoc() function returns SELECT query data as an associative array, where the column names of the returned row are the keys. Quote Link to comment Share on other sites More sharing options...
SanderVh Posted March 11, 2011 Author Share Posted March 11, 2011 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 Quote Link to comment Share on other sites More sharing options...
SanderVh Posted March 12, 2011 Author Share Posted March 12, 2011 I've tried using different places in the different files etc. But the result is always the same error message, is there like a typo I really can't discover? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.