Jump to content

sorting users


RCS

Recommended Posts

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

* 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

<?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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.