Re: Changing URL
| From: | bmay | Date: | Sun, 23 Nov 2003 19:04:27 +0000 |
| Subject: | Re: Changing URL | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-22173@lists.php.net to get a copy of this message | ||
Nik wrote:
OK Guys, It's me a again. My problem now is when I click the submit button, the URL to my php script file is being displayed. That is I have a script doing some validation, and when the user clicks the submit button if there is error in the way the entered their information my url changes to match the location of my php script file. I wish for it to go back to the original url. IMHO a better way to solve your problem is to put the validation PHP code in the html form page with the page posting to itself. The logic could then be:if form variables are present verifiy if error
display warning where you have an error in your formelse
redirect imediately to the next page (<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=http://your next page urll"> i think)endif else // first acces to the page or redirect after error content page display form page endif The use of template engine permit some nice reuse of original html form page. b. PS: an easier way is to simply code a redirect in error page header: <META HTTP-EQUIV="REFRESH" CONTENT="10;URL=http://your form page url"> witch display your error page 10s and redirect to the form page
************* Start of script *** <?PHP //this file is used to verify the user credentials include "db.inc"; session_start(); $login_username = $_POST['user_name']; $login_pass = $_POST['_password']; $user_check = mysql_query("SELECT username FROM users WHERE username='$login_username'"); if (mysql_num_rows($user_check) > 0) { $pass_check = mysql_query("SELECT username,password FROM users WHERE username='$login_username' AND password=MD5('$login_pass')"); if (mysql_num_rows($pass_check)>0) {//put code here to access complaints page and //start sessionsession_register('login_name'); $_SESSION['login_name'] = $login_username; header("Location: issues.php"); //This is when it is successful. Imanage to change the URL when the login is successful.//include "issues.php";} else {include "header.php"; echo "There seems to be an error with your password. Kindly re-enteryour correct password. Thank you!";// header("Location: login.php"); I can't use this since I can't get towrite the error on the pageinclude "login.html"; //and this is allowing it to keep the url ofthe PHP file which is this file } } else { include "header.php"; echo "The specified user name does not exists. Kindly register. Thank you!"; include "signup.html"; include "footer.php"; } ?> *********** end of script *********