Need help with the code

Need help with the code

am 02.10.2009 20:06:33 von Nagendra Prasad

--001517447dc605e4cb0474f7a1db
Content-Type: text/plain; charset=ISO-8859-1

Hi All,

I need some help with the below code. I have this login code with me and its
working fine with my *localhost 'WAMP' *server. But when I tried to run the
same script on my web host server its not working. Every time its giving me
the same message "*please enter a username and a password*" which is a
condition within the script.


session_start();

$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)

{
$connect = mysql_connect("localhost", "tutor_root", "admin") or
die("couldn't connect");
mysql_select_db("tutor_register") or die("couldn't find db");


$query = mysql_query("SELECT * FROM register WHERE username ='$username'");
$numrows = mysql_num_rows($query);
if ($numrows!=1)

{
//code to login

while ($row =mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword= $row['password'];

}
//check to see if they match

if ($username==$dbusername&&$password==$dbpassword)
{
echo "you are in here to enter the members
page";


$_SESSION['username']=$username;

}
else

echo "incorrect password";
}
else

die("That user dosen't exist");


}
else
die("pelase enter a username and a password");



?>

--
Guru Prasad
Ubuntu Voice GTK+ Forum

--001517447dc605e4cb0474f7a1db--

Re: Need help with the code

am 02.10.2009 20:10:26 von Jason Gerfen

nagendra prasad wrote:
> Hi All,
>
> I need some help with the below code. I have this login code with me and its
> working fine with my *localhost 'WAMP' *server. But when I tried to run the
> same script on my web host server its not working. Every time its giving me
> the same message "*please enter a username and a password*" which is a
> condition within the script.
>
>
> > session_start();
>
>
echo var_dump(print_r($_POST));

Are the $_POST['username'] and $_POST['password'] variables present? You
didn't post any html form information so I think you could start there.
> $username = $_POST['username'];
> $password = $_POST['password'];
>
> if ($username&&$password)
>
> {
> $connect = mysql_connect("localhost", "tutor_root", "admin") or
> die("couldn't connect");
> mysql_select_db("tutor_register") or die("couldn't find db");
>
>
> $query = mysql_query("SELECT * FROM register WHERE username ='$username'");
> $numrows = mysql_num_rows($query);
> if ($numrows!=1)
>
> {
> //code to login
>
> while ($row =mysql_fetch_assoc($query))
> {
> $dbusername = $row['username'];
> $dbpassword= $row['password'];
>
> }
> //check to see if they match
>
> if ($username==$dbusername&&$password==$dbpassword)
> {
> echo "you are in here to enter the members
> page";
>
>
> $_SESSION['username']=$username;
>
> }
> else
>
> echo "incorrect password";
> }
> else
>
> die("That user dosen't exist");
>
>
> }
> else
> die("pelase enter a username and a password");
>
>
>
> ?>
>
>


--
Jason Gerfen
Systems Administration/Web application development
jason.gerfen@scl.utah.edu

Marriott Library
Lab Systems PC
295 South 1500 East
Salt Lake City, Utah 84112-0806
Ext 5-9810


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Need help with the code

am 02.10.2009 20:15:23 von Nagendra Prasad

--0023545309288e46630474f7c051
Content-Type: text/plain; charset=ISO-8859-1

OK so here is the form for the below code:




Username:

Password:







--0023545309288e46630474f7c051--

Re: Need help with the code

am 02.10.2009 20:17:08 von Jason Gerfen

nagendra prasad wrote:
> OK so here is the form for the below code:
>
>
>
>


> Username:

> Password:

>
>
>
>

>
>
Did you try looking at the $_POST array data?

echo var_dump(print_r($_POST));


--
Jason Gerfen
Systems Administration/Web application development
jason.gerfen@scl.utah.edu

Marriott Library
Lab Systems PC
295 South 1500 East
Salt Lake City, Utah 84112-0806
Ext 5-9810


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Need help with the code

am 02.10.2009 20:20:28 von Nagendra Prasad

--0023545bdb80bbf5f70474f7d226
Content-Type: text/plain; charset=ISO-8859-1

Yes I did but still its not working on my web server however its working
fine with my WAMP server locally.



On Fri, Oct 2, 2009 at 9:17 PM, Jason Gerfen wrote:

> nagendra prasad wrote:
>
>> OK so here is the form for the below code:
>>
>>
>>
>>


>> Username:

>> Password:

>>
>>

>>
>>
>> Did you try looking at the $_POST array data?
>
> echo var_dump(print_r($_POST));
>
>
> --
> Jason Gerfen
> Systems Administration/Web application development
> jason.gerfen@scl.utah.edu
>
> Marriott Library
> Lab Systems PC
> 295 South 1500 East
> Salt Lake City, Utah 84112-0806
> Ext 5-9810
>
>


--
Guru Prasad
Ubuntu Voice GTK+ Forum

--0023545bdb80bbf5f70474f7d226--

Re: Need help with the code

am 02.10.2009 20:24:20 von Jason Gerfen

Add this to your script and just copy and paste it back. Seriously, you
are not going to get any help if you don't show anyone the output of
your problem.

echo "

";
var_dump(print_r($_GET));
var_dump(print_r($_POST));
echo "
";

If you are not getting anything in the post try changing the method of
your html form to 'get' vs. 'post'
*IE:


And copy and paste the results so we can see where the problem is. If
you are feeling weird about an authentication script contents then
filter the data but don't just leave out parts of the output.

nagendra prasad wrote:
> Yes I did but still its not working on my web server however its
> working fine with my WAMP server locally.
>
>
>
> On Fri, Oct 2, 2009 at 9:17 PM, Jason Gerfen
> > wrote:
>
> nagendra prasad wrote:
>
> OK so here is the form for the below code:
>
>
>
>
> Username:

> Password:

>
>
>
>
> Did you try looking at the $_POST array data?
>
>
> echo var_dump(print_r($_POST));
>
>
> --
> Jason Gerfen
> Systems Administration/Web application development
> jason.gerfen@scl.utah.edu
>
> Marriott Library
> Lab Systems PC
> 295 South 1500 East
> Salt Lake City, Utah 84112-0806
> Ext 5-9810
>
>
>
>
> --
> Guru Prasad
> Ubuntu Voice GTK+ Forum


--
Jason Gerfen
Systems Administration/Web application development
jason.gerfen@scl.utah.edu

Marriott Library
Lab Systems PC
295 South 1500 East
Salt Lake City, Utah 84112-0806
Ext 5-9810


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Need help with the code

am 02.10.2009 21:27:44 von Jason Gerfen

Maybe you should google for information regarding the php.ini and error
reporting.
nagendra prasad wrote:
> Yes I did but still its not working on my web server however its working
> fine with my WAMP server locally.
>
>
>
> On Fri, Oct 2, 2009 at 9:17 PM, Jason Gerfen wrote:
>
>
>> nagendra prasad wrote:
>>
>>
>>> OK so here is the form for the below code:
>>>
>>>
>>>
>>>


>>> Username:

>>> Password:

>>>
>>>

>>>
>>>
>>> Did you try looking at the $_POST array data?
>>>
>> echo var_dump(print_r($_POST));
>>
>>
>> --
>> Jason Gerfen
>> Systems Administration/Web application development
>> jason.gerfen@scl.utah.edu
>>
>> Marriott Library
>> Lab Systems PC
>> 295 South 1500 East
>> Salt Lake City, Utah 84112-0806
>> Ext 5-9810
>>
>>
>>
>
>
>


--
Jason Gerfen
Systems Administration/Web application development
jason.gerfen@scl.utah.edu

Marriott Library
Lab Systems PC
295 South 1500 East
Salt Lake City, Utah 84112-0806
Ext 5-9810


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Need help with the code

am 02.10.2009 21:33:27 von Nagendra Prasad

--001517402a00bdfcdc0474f8d763
Content-Type: text/plain; charset=ISO-8859-1

hay so I have solved the issue. The problem was with my login HTML page.
Anyways thanks everyone for quick responses :)

--001517402a00bdfcdc0474f8d763--