DoQtor N0 Posted February 5, 2011 Share Posted February 5, 2011 I am new so please forgive me if my questions are very very simplistic in nature. After my user logs in successfully, how can I have the new screen to display their name? I capture their name in the code already. Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/ Share on other sites More sharing options...
jcbones Posted February 5, 2011 Share Posted February 5, 2011 How you capture the name, is strictly tied to how you display it. In short, we need to see some code: Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170260 Share on other sites More sharing options...
colap Posted February 5, 2011 Share Posted February 5, 2011 I am new so please forgive me if my questions are very very simplistic in nature. After my user logs in successfully, how can I have the new screen to display their name? I capture their name in the code already. Post code. Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170265 Share on other sites More sharing options...
DoQtor N0 Posted February 5, 2011 Author Share Posted February 5, 2011 Here is the code from the checkuser.php <? /* Check User Script */ session_start(); // Start Session include 'db.php'; // Conver to simple variables $username = $_POST['username']; $password = $_POST['password']; if((!$username) || (!$password)){ echo "Please enter ALL of the information! <br />"; include 'Client_ActErr.php'; exit(); } // Convert password to md5 hash $password = md5($password); // check if the user info validates the db $sql = mysql_query("SELECT * FROM Clients WHERE username='$username' AND password='$password' AND activated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ foreach( $row AS $key => $val ){ $$key = stripslashes( $val ); } // Register some session variables! session_register('first_name'); $_SESSION['first_name'] = $first_name; session_register('last_name'); $_SESSION['last_name'] = $last_name; session_register('email_address'); $_SESSION['email_address'] = $email_address; session_register('special_user'); $_SESSION['user_level'] = $user_level; mysql_query("UPDATE Clients SET last_login=now() WHERE pk_client_id ='$userid'"); header("Location: index.html"); } } else { //echo "You could not be logged in! Either the username and password do not match or you have not validated your registration!<br /> //Please try again!<br />"; include 'Client_ActErr.php'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170270 Share on other sites More sharing options...
colap Posted February 5, 2011 Share Posted February 5, 2011 header("Location: filename.html"); In filename.html echo $_SESSION['first_name']; Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170274 Share on other sites More sharing options...
DoQtor N0 Posted February 5, 2011 Author Share Posted February 5, 2011 Here's what i have... <div id = "leftside"> <p> <span class="style14 style5 style15"><a href="client_page.php"><img src="media/client_login_ov.gif" width="180" height="28" border="0"></a></span><a href="#"></a><br> <br> <? if(!$first_name){ echo $_SESSION['first_name']; <br /> } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170287 Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 <?php // <--- always use full tag syntax session_start(); // <--- must include session_start() before using session data if(!$first_name){ // <--- this appears to be undefined, therefore will always return TRUE echo $_SESSION['first_name']; <br /> } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170291 Share on other sites More sharing options...
DoQtor N0 Posted February 5, 2011 Author Share Posted February 5, 2011 The main screen comes up and I have a Client login button on it. Once the client logs in, I would like to replace the client login button with a "Welcome Mr Smith". Once they logout, the Client Login button reappears. Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170306 Share on other sites More sharing options...
BlueSkyIS Posted February 5, 2011 Share Posted February 5, 2011 did you update your code based on Pikachu2000's observations and suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170317 Share on other sites More sharing options...
ZulfadlyAshBurn Posted February 5, 2011 Share Posted February 5, 2011 I used this script on my own website and its working. coded by myself though <?php session_start(); if(!isset($_SESSION['first_name'])){ echo "<form action='checkuser.php' method='post' name='login'> Username:<br><input class='login' name='username' type='text' value=''> Password:<br><input class='login' name='password' type='password' value=''><br><input name='Submit' type='submit' value='SUBMIT!'> </form>"; } else { echo "<center> Welcome, "; echo ($_SESSION['first_name']); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226788-after-successful-loginwhat-next/#findComment-1170343 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.