Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5238

Re: php code

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: php code
Date Mon, 26 Mar 2012 18:21:27 +0200
Lines 81
Message-ID <9tbjc7FajkU1@mid.individual.net> (permalink)
References <7f2e4383-cbef-475b-b737-c11882262909@to5g2000pbc.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net IENpxVyKO/8ZBuEX5oJvxwamSZOub9WG7P4iw4OLZJkXWNNh/D
Cancel-Lock sha1:em/JClDq/GmZT33bDHkKNK40bXQ=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120321 Firefox/11.0 SeaMonkey/2.8
In-Reply-To <7f2e4383-cbef-475b-b737-c11882262909@to5g2000pbc.googlegroups.com>
X-Received-Bytes 2373
Xref csiph.com comp.lang.php:5238

Show key headers only | View raw


shaurya077 wrote:
> hi frds .....
> i'm working on a small assignment based on php
> in this assignment i just created a login page (username and password
> required)
> but it is working all right
> but after login there i created a welcome page but in which welcome
> page php scripts didn't showing the name of user
>
> like "hi! shaurya"
>
> my php code is for login check:
>
> <?php
>
> include("config.php");
>
> session_start();
>
> if($_SERVER["REQUEST_METHOD"]=="POST")
> {
> $myusername=addslashes($_POST['user_name']);
> $mypassword=addslashes($_POST['pass_word']);
>
>
> $sql="select id from userinformation WHERE username='$myusername' and
> password='$mypassword' ";
>
> $result=mysql_query($sql);
>
> $row=mysql_fetch_array($result);
>
> $active=$row['active'];
>
> $count=mysql_num_rows($result);
>
> if($count==1)
> {
> session_register("myusername");

session_register is deprecated and shouldn't be used.

> $_SESSION['login_user']=$myusername;

this is enough to store a value to the session.

> header("location:welcome.php");
> }
> else
> {
> $error="name and password is invalid";
>
> echo $error;
>
>
> }
> }
>
>
> ?>
>
> this scripts is used to check the data filled bu user and after that
> this welcome page comes (code):
>
> <?
>
> //screen after verification
>
> include('lock.php');
>
> echo $login_session;

If you use the same variable as you had in storing the user name to the 
session, then you would get the name.




-- 

   //Aho

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

php code shaurya077 <suchaitgaurav221.kv3@gmail.com> - 2012-03-26 08:05 -0700
  Re: php code "J.O. Aho" <user@example.net> - 2012-03-26 18:21 +0200
  Re: php code "Peter H. Coffin" <hellsop@ninehells.com> - 2012-03-26 11:03 -0500
  Re: php code Denis McMahon <denismfmcmahon@gmail.com> - 2012-03-26 20:49 +0000
    Re: php code Michael Fesser <netizen@gmx.de> - 2012-03-27 05:54 +0200
  Re: php code Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-03-27 10:37 +0200

csiph-web