Jump to content

Recommended Posts

Hi all,

I am going bald on this one. :confused:

I wonder what could be wrong. I could login to my local server but cant login in a live server!

 

thanks all

 

 

<?php



if(isset($_POST['login'])){



$tbl_name="reg_users";



// Define $myusername and $mypassword

$username=$_POST['username'];

$password=$_POST['password'];



// To protect MySQL injection

$username = stripslashes($username);

$password = stripslashes($password);

$username = mysql_real_escape_string($username);

$password = mysql_real_escape_string($password);



if($username == ''){

    echo  "<font color='red' size='-2'><b>Pls Enter User ID</b></font>";

}

if($password == ''){

    echo "<font color='red' size='-2'><b>Pls Enter Password</b></font>";

}else{

$crypt_pass = md5($password);



//check for existance of username and password

$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$crypt_pass'";

$result=mysql_query($sql);



// Mysql_num_row is counting table row

$count=mysql_num_rows($result);



// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){

    

// Register username and password and redirect to login page"

$_SESSION['username'] = $username;

$_SESSION['password'] = $password;



header("location: ../folder/filename.php");

exit();

}

else {

//if no match found, echo out error message

echo "<font color='red' size='2'><b>Invalid User ID or Password</b></font><br>";

}    }

 }

ob_end_flush();

?>
Link to comment
https://forums.phpfreaks.com/topic/275803-what-could-be-wrong/
Share on other sites

It depends on what you mean by "doesn't work", but it sounds like your live server doesn't have short tags enabled.

doesnt work means i could not redirect to my intended page. and how do i check if my live server doesn't have short tags enable and can i enable(nope i guess)

what beats me is that it works on my wamp and i could reach other pages in my target directory

Link to comment
https://forums.phpfreaks.com/topic/275803-what-could-be-wrong/#findComment-1419411
Share on other sites

what beats me is that it works on my wamp and i could reach other pages in my target directory

Wamp has short tags enabled, your live server probably doesn't. You can easily check this. If short tags are disabled you'll see, as plaintext:
action="<?= $_SERVER['PHP_SELF'] ?>"
In your browser view source.
Link to comment
https://forums.phpfreaks.com/topic/275803-what-could-be-wrong/#findComment-1419414
Share on other sites

You're not giving us nearly enough information to help you.

Where exactly is the problem?

 the problem is that when the username and password is entered, it suppose to redirect to an index but it is not redirecting, but again i could access other pages inside the target folder (which means the session have been set. because it displays the welcome username)

Link to comment
https://forums.phpfreaks.com/topic/275803-what-could-be-wrong/#findComment-1419477
Share on other sites

What debugging steps have you taken?

Make sure error_reporting is set to E_ALL or -1 and display_errors is set to ON or 1

It may help to post the form

 

I do not have control over my live server (host) but from my localhost, all is working fine!

 

Link to comment
https://forums.phpfreaks.com/topic/275803-what-could-be-wrong/#findComment-1419569
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.