You are here: Re: simple login script issue « All PHP « IT news, forums, messages
Re: simple login script issue

Posted by Dave Nash on 12/15/06 07:54

On Fri, 15 Dec 2006 16:31:28 +1000, "Vince Morgan"
<vinhar@REMOVEoptusnet.com.au> wrote:

>"Dave Nash" <kabooby2004@yahoo.com> wrote in message
>news:f7e4o29rdsjmhre3f5c19da7kj9ce8p2b0@4ax.com...
>> On Fri, 15 Dec 2006 15:48:41 +1000, "Vince Morgan"
>> <vinhar@REMOVEoptusnet.com.au> wrote:
>>
>> >"Dave Nash" <kabooby2004@yahoo.com> wrote in message
>> >news:42c2o2doksnuc6dr3omeu17u5gtetd97dj@4ax.com...
>> >> On Thu, 14 Dec 2006 13:47:02 +1000, "Vince Morgan"
>> >> <vinhar@REMOVEoptusnet.com.au> wrote:
>> >>
>> >> >"Dave Nash" <kabooby2004@yahoo.com> wrote in message
>> >> >news:09d1o2du54l5fh9813evr2htr02udsrj8l@4ax.com...
>> >> >> I have a login form setup. When a person logs in it verified the
>user
>> >> >> name and password and logs them in if the information is correct.
>> >> >> This script is called auth.php as in included in all of the pages I
>> >> >> want to secure.
>> >> >> My problem is how do I get info on that particular logged in user.
>> >> >> example say Welcome $fullname when the only two fields ive currently
>> >> >> go are u_name and p_word.
>> >> >> See auth script below.
>> >> >>
>> >> >> And
>> >> >>
>> >> >> How to get info from another table?
>> >> >>
>> >> >> Example SELECT * FROM messages WHERE userid = $userid ORDER by
>> >> >> messageid
>> >> >>
>> >> >> -------------------------------
>> >> >> Auth.php
>> >> >>
>> >> >> session_start();
>> >> >> if($_POST){
>> >> >> $_SESSION['u_name']=$_POST["u_name"];
>> >> >> $_SESSION['p_word']=$_POST["p_word"];
>> >> >> }
>> >> >> $result=mysql_query("select * from users
>> >> >> where u_name='" . $_SESSION['u_name'] . "' and p_word='" .
>> >> >> $_SESSION['p_word'] . "'");
>> >> >> $num=mysql_num_rows($result);
>> >> >> if($num < 1){
>> >> >> echo "show login form";
>> >> >> exit;
>> >> >> }
>> >> >> End auth.php
>> >> >> -------------------------------
>> >> >> Tables are as follows.
>> >> >> Users table.
>> >> >> userid
>> >> >> u_name
>> >> >> p_word
>> >> >> fullname
>> >> >> PRIMARY KEY (`userid`)
>> >> >
>> >> >The above looks like one table named "Users", with five fields.
>> >> >If so,
>> >> >"SELECT fullname FROM Users WHERE userid = '".$userid.'"';
>> >> >If not, I'm lost :)
>> >> >Vince Morgan
>> >>
>> >> But this is the problem. the auth script only retrieves the values
>> >> u_name and p_word.
>> >>
>> >> how do I use the select query like youve said If I cant get the value
>> >> $userid
>> >>
>> >> Example.
>> >>
>> >> I need to get all values from the users table that matches the $u_name
>> >> value used to login.
>> >>
>> >>
>> >>
>> >Do you have [userid, u_name, p_word, fullname] in one table? Or more
>than
>> >one table?
>> >Vince Morgan
>> >
>>
>> here are the tables I have.
>>
>> <users>
>> userid
>> u_name
>> password
>> email_address
>>
>> <messages>
>> messageid
>> message
>> userid
>>
>> <items>
>> itemid
>> itemtitle
>> item
>> userid
>>
>> I would like to get info out of any of these tables based on the
>> userid.
>If the "username" field is UNIQUE you don't need to include "password" in
>the query.
>"SELECT userid FROM users WHERE u_name = '".$username."'"." AND password =
>'"".$password."'"
>Now you will have the userid and can use that as the key into the other
>tables.
>"SELECT * FROM messages WHERE userid = '".$userid."'"
>"SELECT * FROM items WHERE userid = '".$userid."'"
>HTH
>Vince Morgan
>

Hi Vince.
Ive tried this, but no good.

Ive setup up a link to grab the userid variable on the index page once
logged in, but it doesnt seem to work.

<?php echo"<a href=\"file.php?userid=" . $_SESSION['userid'] . "\"
class=\"a\">Link</a>"; ?>

but when I use the u_name variable it works fine.

<?php echo"<a href=\"file.php?u_name=" . $_SESSION['u_name'] . "\"
class=\"a\">Link</a>"; ?>

This is my query.
"select userid from users
where u_name='" . $_SESSION['u_name'] . "' and p_word='" .
$_SESSION['p_word'] . "'"

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация