php code working on localhost but not working online

hi frds

I am using a php script for login page that is working nicely on my localhost but not working online
plz help urgentlly

php code for login:

<?php include('config.php'); session_start(); if($_SERVER["REQUEST_METHOD"]=="POST") { $myusername=addslashes($_POST['user_name']); $mypassword=addslashes($_POST['pass_word']); $mypassword=md5($mypassword); $sql="select id from userinformation2 WHERE username='$myusername' and password='$mypassword' "; $result=mysql_query($sql); $row=mysql_fetch_array($result); $active=$row['active']; $count=mysql_num_rows($result); if($count==1) { session_register("myusername"); $_SESSION['login_user']=$myusername; header("location:welcome.php"); } else { $error="name and password is invalid"; echo $error; } } ?>

Can you be more specific with “not working”? Are you getting any errors? More details, man! More details!

[php]
$sql="select id from userinformation2 WHERE username=’$myusername’ and password=’$mypassword’ ";

$result=mysql_query($sql);

$row=mysql_fetch_array($result);

$active=$row[‘active’];
[/php]
In your query you’ve asked it to take the column ‘id’ from the database, and then set the result in an array called $row. The only values that will be available in this is $row[‘id’] yet you’re asking it to look for $row[‘active’].

I have no idea how you would even get that to work on localhost at all.

Sponsor our Newsletter | Privacy Policy | Terms of Service