RCS Posted May 8, 2008 Share Posted May 8, 2008 Hi all, I'm trying to create a user interface, I have created database, reg form and action script for sending info to database. Now I'm trying to create a script that will redirect users to thier pages after they login, my problem is how do I do this so that I'm calling only that users information and not all information in the user table. If someone can help me out with this it would be greatly appreciated. Thanks in advance. include($_SERVER["DOCUMENT_ROOT"]."/include/dbinfo.inc"); $con = mysql_connect($db_host, $db_user, $db_pass) or die ("Could not make connection to database."); mysql_select_db($db_name) or die ("Unable to select database!"); $sql="SELECT * FROM admin WHERE ???????????? Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/ Share on other sites More sharing options...
947740 Posted May 8, 2008 Share Posted May 8, 2008 $sql = "SELECT * FROM admin WHERE user = \"$user\""; Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535906 Share on other sites More sharing options...
RCS Posted May 8, 2008 Author Share Posted May 8, 2008 * admin should be user $sql="SELECT * FROM user WHERE userName = not sure I understand \$user\ My user database set up is like firstName lastName dob email phone address city state country zip userName password description content and I only want to call that users information and not all information in the user table are you saying to create something like $myusername=$_POST['userName']; $mypassword=$_POST['password']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM user WHERE userName = $myusername Well I tried this but it did not work, not really sure how to do it?????? Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535915 Share on other sites More sharing options...
947740 Posted May 8, 2008 Share Posted May 8, 2008 <?php $myusername=$_POST['userName']; $mypassword=$_POST['password']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM user WHERE userName = \"$myusername\""; // That is the query // Do not forget about connecting to the database and performing the query ?> Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535919 Share on other sites More sharing options...
RCS Posted May 8, 2008 Author Share Posted May 8, 2008 it there some way for me to call the info from the database as a link to that users information??? for example somesite.com/username or somesite.com/index.php?username Then it would call all information stored in row userName what ever the users name is. ???? Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535925 Share on other sites More sharing options...
947740 Posted May 8, 2008 Share Posted May 8, 2008 Yes. It starts getting more complicated when you do this. I would use the second form. e.g. yoursite.com/user.php?user=iloveapples You would then use a $_GET['user'] statement in user.php, and then you would perform a query to gather the information about that user. Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535926 Share on other sites More sharing options...
RCS Posted May 8, 2008 Author Share Posted May 8, 2008 I tried this code and I just get Wrong Username or Password and I have entered user and pass correct, not sure why its not working. <?php /** * @author * @copyright 2008 */ include($_SERVER["DOCUMENT_ROOT"]."/include/dbinfo.inc"); $con = mysql_connect($db_host, $db_user, $db_pass) or die ("Could not make connection to database."); mysql_select_db($db_name) or die ("Unable to select database!"); $myusername=$_POST['userName']; $mypassword=$_POST['password']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM user WHERE userName = \"$myusername\" and PASSWORD = \"$mypassword\" "; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("userName"); session_register("PASSWORD"); header("location:index.php"); } else { echo "Wrong Username or Password"; } ?> Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535928 Share on other sites More sharing options...
RCS Posted May 8, 2008 Author Share Posted May 8, 2008 ok that was a form issue, but now I'm just rediecting to the index.php page now and I want to do something like I was saying with somesite.com/index.php?username and redirect the user to the row that hold there info. any ideas how I can do this???? Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535935 Share on other sites More sharing options...
947740 Posted May 8, 2008 Share Posted May 8, 2008 Yes. It starts getting more complicated when you do this. I would use the second form. e.g. yoursite.com/user.php?user=iloveapples You would then use a $_GET['user'] statement in user.php, and then you would perform a query to gather the information about that user. Link to comment https://forums.phpfreaks.com/topic/104709-sorting-users/#findComment-535999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.