I am working on a project and I need to run my program on another web server. This is a pretty simple login page that I'm having a problem with. The program works correctly if I run it through the local host through WAMP. The problem I encountered is that part of the redirect is not working properly, it checks the user and starts the session, but when he receives the redirect, nothing happens.
I either do something wrong with my syntax, which, I think, is unlikely, since it works correctly through my local host. Or, alternatively, I think that the server does not have this function (I'm not sure that you can choose which modules are supported by your server, although I am sure that this is possible).
I donβt know if it matters, but they use "cpanel", where I can access the files and everything is in the same directory, so if someone can tell me where I am wrong, or offer an alternative to redirecting via "header "any help would be greatly appreciated. I looked around, but it seems that the "headline" is a standard workhorse.
Here is the code I have:
if( (!empty($_POST['username'])) && (!empty($_POST['password'])) ) { // username and password sent from Form $myusername = $_POST['username']; $mypassword = $_POST['password']; $sql="SELECT UserName FROM User WHERE UserName='$myusername' and Password='$mypassword'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); //$active=$row['active']; $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1) { echo "we made if to the if"; session_start(); session_register("myusername"); $_SESSION['login_user']=$myusername; echo "right b4 the re-direct"; header("location: UI.php"); exit; } else echo "Your user name/password was not correct pleast TRY AGAIN!!!"; }
Update: in response to the statements about the echo, there would be a problem that I process my form in the same file and use echo $ _SERVER ['PHP_SELF']
redirect php
cpowel2
source share