Need help with PHP urgent?
-
login-form.php <?php require("do_html_header.php"); do_html_header(); ?> <body bgcolor="00FFCC"> <form id="loginForm" name="loginForm" method="post" action="login-exec.php"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <table width="300" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td width="112"><b>Login</b></td> <td width="188"><input name="login" type="text" class="textfield" id="username" /></td> </tr> <tr> <td><b>Password</b></td> <td><input name="password" type="password" class="textfield" id="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Login" /></td> </tr> </table> </form> <center>Not yet a member? <a href="registration.php">Register</a></ce… </body> </html> login-exec.php <?php //Start session session_start(); //Include database connection details require_once("config.php"); require("clean.php"); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Sanitize the POST values $username = clean($_POST['username']); $password = clean($_POST['password']); //Input Validations if($username == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } //If there are input validations, redirect back to the login form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.php"); exit(); } //Create query $qry="SELECT * FROM users WHERE username='$username' AND password='$password'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $MEMBER = mysql_fetch_assoc($result); $_SESSION['SESS_USERNAME'] = $MEMBER['username']; $_SESSION['SESS_FIRST_NAME'] = $MEMBER['fname']; $_SESSION['SESS_LAST_NAME'] = $MEMBER['lname']; //print "Login success!"; session_write_close(); header("location: jobsmatchindex.php"); exit(); } else { //Login failed header("location: login-failed.php"); exit(); } } else { die("Query failed"); } ?>
-
Answer:
Are you sure it doesn't get past the login-form.php, or it flickers a bit when you submit, If it does it probably is submitted and since the validation fails, it gets back to the login-form.php. if any of the following condition occurs the code instructs to jump back to login-form.php by setting $errflag==true. $password == '' $username== '' mysql_num_rows($result) != 1 check properly by providing a valid userid and password and this may not happen.
Gab at Yahoo! Answers Visit the source
Other answers
Too much crap on this script... Try the free "Login script" from http://web2coders.com - 749 downloads to date.
just "JR"
You call header() after you already sent the header. This function can only be used before one single byte is sent.
Dozo
Related Q & A:
- I need help on what I need to buy or do.Best solution by Yahoo! Answers
- I need help with some horse questions, can you help me.Best solution by Yahoo! Answers
- I did something really bad and now i need help please help me.Best solution by Yahoo! Answers
- Help with itouch urgent?Best solution by Yahoo! Answers
- What sort of opportunities are there to help people in Africa or places where people need help?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.