![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Posts: 16
Rep Power: 0
![]() |
Urgent help needed with login form
I wrote a login form to access the admin area of my program. It takes the username and password selects them from the db based on the username and compares them to the values taken in. All seems well codewise but the program just reloads the form no error, no continuation to the next page... any ideas?
Thanks in advance, i have written this script which is used for logging users into an admin area. From what i can see its perfectly okay but... when i hit submit it just reloads the form [php]<?php if(!$submit) { ?> <html> <head> <title>User Login</title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /> <input type="submit" name="submit" value="Login" /><br /> </div> </form> </body> </html> <?php } else { include ("db.php"); $sql = mysql_query("SELECT user_name, user_password FROM core_users WHERE user_name = '$username'"); $fetch_em = mysql_fetch_array($sql); if($username == $fetch_em["user_name"] && $password == $fetch_em["user_password"]) { session_start(); session_register("sessionvar"); $id = session_id(); //gets the session id if cookies are disabled $url = "Location: admin_launch.php?sid=" . $id; header($url); } else { ?> <html> <head> <title>User Login</title> </head> <body> <span style="color:#ff0000;">Password/Username Is Invalid</span><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /> <input type="submit" name="submit" value="Login" /><br /> </div> </form> </body> </html> <?php } } ?>[/php] Last edited by big_k105; Apr 8th, 2005 at 10:03 AM. Reason: added php tags |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
running your code in my mind, I noticed you dont adress the form variables correctly change the submit check to !isset($_POST['submit']) and the variable $username with {$_POST['username']} i think this should solve your problem
tell me if not -codetaino EDIT: Atention: Notice that your form send the variables as post and in order to access those variables you need to write $_POST['nameoffield']. English is not my first language and sometimes is hard for me to explain myself so... ask me if you need further help or explanation
__________________
"God bless u all" :) Last edited by codetaino; Apr 8th, 2005 at 7:52 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|