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 Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/ 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. Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-171940 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. Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172004 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. Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172007 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 Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172018 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 Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172021 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} Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172054 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 Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172127 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']) Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172131 Share on other sites More sharing options...
Snooble Posted January 29, 2007 Author Share Posted January 29, 2007 thank you Link to comment https://forums.phpfreaks.com/topic/36193-solved-echoing-a-mysql-cell/#findComment-172307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.