Log in

View Full Version : [PHP] script not running.



lolwut
22-08-2007, 11:05 AM
iyaar,

I coded this PHP script recently and there's a error saying "Password was incorrect." even when it is correct.

Link: http://edd-dev.awardspace.com/php/index.php

Page code:


<?php
$pass1 == 'admin';//Login pass.

if(!$_POST['submit']){
echo("
<form action=\"index.php\" method=\"POST\">
PASSWORD: <input type=\"text\" name=\"password\">
<br />
<input type=\"submit\" name=\"submit\" value=\"LOGIN\">
</form>
");
}else{
$password == $_POST['password'];
if($password == $pass1){
echo("The password was correct.");
}else{
echo("The password was incorrect.");
}
}
?>
I dunno what's wrong so any help appreciated! (:

Tomm
22-08-2007, 11:10 AM
== is a comparison.
= is used to set variables etc.

RYANNNNN
22-08-2007, 12:50 PM
Yeah as Tom said, you need to change $pass1 == 'admin';//Login pass. to $pass1 = 'admin';//Login pass.

At the moment your $pass1 isn't actually defined.

lolwut
22-08-2007, 04:30 PM
*feels dumb.
*sobs.

Thanks, fixed, works fine. +Rep to Tomm. (:

Eric30
22-08-2007, 07:01 PM
you should use

===

as in


if($password === $pass1){


=== means idenctal to,

this way it will check caps in your pass
ie;

password == PaSSwOrD //Returns true,
password === PaSSwOrD //Returns false,

Invent
22-08-2007, 08:16 PM
Um, you can just use "==" as that is also case-sensitive. Or it is atleast in the PHP Version(s) I've used/using...

Want to hide these adverts? Register an account for free!