monsterphp Posted August 3, 2013 Share Posted August 3, 2013 Hello, I have this code snippet that should pull in the information from my database, in this case username and email address: <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> <h1>Member Area</h1> <pThanks for logging in! You are $lt;b><? echo $_SESSION['Username'] ?></b> and your email address is <b><? echo $_SESSION['EmailAddress']?></b>.</p> <?php The problem is- it does not pull them in and when I test my web page, it will only bring up this: Member Areaand your email address is I can verify that the information is stored in the database at this point. What shall I do? Thank you for helping. Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/ Share on other sites More sharing options...
mac_gyver Posted August 3, 2013 Share Posted August 3, 2013 what does the 'view source' of the page show in your browser? Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/#findComment-1443362 Share on other sites More sharing options...
KevinM1 Posted August 3, 2013 Share Posted August 3, 2013 There's nothing in the code you provided that has anything to do with information retrieval from a database. Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/#findComment-1443364 Share on other sites More sharing options...
Barand Posted August 3, 2013 Share Posted August 3, 2013 (edited) There are, however, several HTML errors involving missing < and > characters around tags Edited August 3, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/#findComment-1443369 Share on other sites More sharing options...
monsterphp Posted August 4, 2013 Author Share Posted August 4, 2013 Thank you for the swift responce! The problem is, it just shows blank fields after I had already created a user in my database. Here is all the source code on index.php: <?pphp include "base.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="main"> <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> <h1>Member Area</h1> <pThanks for logging in! You are <b><?=$_SESSION['Username']?></b> and your email address is <b><?=$_SESSION['EmailAddress']?></b>.</p> <?php } elseif(!empty($_POST['username']) && !empty($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST['password'])); $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'"); if(mysql_num_rows($checklogin) == 1) { $row = mysql_fetch_array($checklogin); $email = $row['EmailAddress']; $_SESSION['Username'] = $username; $_SESSION['EmailAddress'] = $email; $_SESSION['LoggedIn'] = 1; echo "<h1>Success</h1>"; echo "<p>We are now redirecting you to the member area.</p>"; echo "<meta http-equiv='refresh' content='=2;index.php' />"; } else { echo "<h1>Error</h1>"; echo "<p>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</p>"; } } else { ?> <h1>Member Login</h1> <p>Thanks for visiting! Please either login below, or <a href="register.php">click here to register</a>.</p> <form method="post" action="index.php" name="loginform" id="loginform"> <fieldset> <label for="username">Username:</label><input type="text" name="username" id="username" /><br /> <label for="password">Password:</label><input type="password" name="password" id="password" /><br /> <input type="submit" name="login" id="login" value="Login" /> </fieldset> </form> <?php } ?> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/#findComment-1443389 Share on other sites More sharing options...
jazzman1 Posted August 4, 2013 Share Posted August 4, 2013 You should also learn how to debug your scripts. Php provides a lots of good debugging functions itself. Have you ever heard about them? Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/#findComment-1443392 Share on other sites More sharing options...
monsterphp Posted August 4, 2013 Author Share Posted August 4, 2013 You should also learn how to debug your scripts. Php provides a lots of good debugging functions itself. Have you ever heard about them? No I haven't. Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/#findComment-1443393 Share on other sites More sharing options...
jazzman1 Posted August 4, 2013 Share Posted August 4, 2013 Read them: 1. Find a good php editor 2. Php security tutorial 3. Debugging: A Beginner's guide 4. How To Ask Questions The Smart Way 5. PHP Resources & FAQs Quote Link to comment https://forums.phpfreaks.com/topic/280803-not-pulling-in-database-info/#findComment-1443414 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.