Jump to content

getting info from a text field


asherinho

Recommended Posts

Hi! I have a log in form which takes user name and password,but the information in these fields seems not be fetched by the php page & I get a message "You forgot to enter the username or password" whenever I enter the username & password.here are the codes for the form and php page

 

<form action="login.php" method="post">

                          <B>USER NAME</B>   <INPUT type="text" name="uname" size="25"><BR><BR>

                          <B>PASSWORD</B>   <INPUT type="password" name="pass" size="25"><BR><BR>

                          <INPUT type="submit" name="submit" size="30" value="LOGIN">

                        </form>

 

if($uname && $pass){

  if($logged_in_user==$uname){

if($record["status"]=="administrator"){require("iframe_adm.php"); exit;}

    elseif($record["status"]=="user"){require("iframe_usr.php"); exit; }

echo "<B style='color:red;font-size:15px'>YOU ARE ALREADY LOGGED IN!</B><BR>";

}

 

$db=mysql_connect("localhost","root");

mysql_select_db("ppra_flis",$db);

$result=mysql_query("select * from login where uname='".$uname."' and pass='".$pass."'");

if(!$result){echo "error in query";}

 

if(mysql_num_rows($result) > 0){

    $logged_in_user=$uname;

    session_register("logged_in_user");

    while($record=mysql_fetch_assoc($result)){

    if($record["status"]=="administrator"){require("iframe_adm.php"); exit;}

        elseif($record["status"]=="user"){require("iframe_usr.php");exit;}

                                          }

                  exit;

                                                        }

 

                else{require("top.php"); echo "<B style='color:red;font-size:15px'>Wrong username or password</B>";}

}

else{require("top.php"); echo "<B style='color:red;font-size:15px'>You forgot to enter the username or password</B>";}

Link to comment
https://forums.phpfreaks.com/topic/113691-getting-info-from-a-text-field/
Share on other sites

all i can do reccomend some easy reading. W3Schools is a good place to start:

http://www.w3schools.com/php/php_forms.asp

 

and this is about a login system, as i didnt quite understand what was going on in your script:

http://phpeasystep.com/workshopview.php?id=6

 

Good Luck!

It is working but I am getting this warning and I don't know how to solve it

 

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

 

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.