Snooble Posted January 29, 2007 Share Posted January 29, 2007 Hello everyone,I want to show the user his/her email address they signed up with. It's stored in a database.how would i echo their email to them once they're logged in with thier username and password?The field is called "Email".Is that understandable? Just like:Once the user is logged in it should show there email where it once said "log in". I believe it should be a isset(); or if statement. But i'm not sure.ThanksSnooble Quote Link to comment Share on other sites More sharing options...
trq Posted January 29, 2007 Share Posted January 29, 2007 Post the code you have for logging in a user. Quote Link to comment Share on other sites More sharing options...
Snooble Posted January 29, 2007 Author Share Posted January 29, 2007 [code]<?php$host="**********"; // Host name$username="********"; // Mysql username$password="**********"; // Mysql password$db_name="************"; // Database name$tbl_name="web_members"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// username and password sent from signup form$myemail=$_POST['myemail'];$mypassword=$_POST['mypassword'];$sql="SELECT * FROM $tbl_name WHERE Email='$myemail' and Password='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myemail and $mypassword, table row must be 1 rowif($count==1){// Register $myusername, $myemail and redirect to file "login_success.php"session_register("myemail");session_register("mypassword");header("location:login_success.php");}else {echo "Wrong Username or Password";}?>[/code]I believe that is what you want. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 print $_SESSION['myemail'];session_register is deprecated, use $_SESSION['myemail'] = $email; instead. Quote Link to comment Share on other sites More sharing options...
Snooble Posted January 29, 2007 Author Share Posted January 29, 2007 thank you. I heard about it being depreciated but "if it works dont fix it" but i will now you have given me the alternative.I prefer echo. I heard it works a point of a second faster lol :)Good old lynda.comSnooble Quote Link to comment Share on other sites More sharing options...
Snooble Posted January 29, 2007 Author Share Posted January 29, 2007 also, sorry to double post but i need some code that checks whether the user is logged in. What would it be?Snooble Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 Why don't you try to write some first and then we'll help when you get stuck. You'll need to use if($condition){ //do}else{//do this} Quote Link to comment Share on other sites More sharing options...
Snooble Posted January 29, 2007 Author Share Posted January 29, 2007 I need to know the condition. I know very basic if else stuff but i dont know the condition name for being logged in. Snooble Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 When they login, set their username in the session, then check to see if the session variable exists.$_SESSION['username'] = $username;thenif($_SESSION['username']) Quote Link to comment Share on other sites More sharing options...
Snooble Posted January 29, 2007 Author Share Posted January 29, 2007 thank you 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.