Basic login (if $pass == "hello") failing.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
m0u53m4t
Forum Contributor
Posts: 101
Joined: Wed Apr 19, 2006 7:47 am
Location: Wales

Basic login (if $pass == "hello") failing.

Post by m0u53m4t »

Whats wrong?

Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home/gelid/domains/gelidscripts.frih.net/public_html/rs/login.php on line 4

Code: Select all

<?php
$username = $_POST['usr'];
$password = $_POST['pass'];
if $username == "Taner131" && $password == "kaitneks"
{
die('Correct, you logged in.');
}
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

if ($username == "Taner131" && $password == "kaitneks")

Why do you create new global variables? why not simply use $_POST['usr'] and $_POST['pass']?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

http://www.php.net/if

if (expr)
statement

notice that you need to place your expression between round braces...
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

i use this to log into admin area for guestbook

Post by akimm »

Code: Select all

<?php
if($_POST['name'] == "###your name###" && $_POST['pass'] == "###your pass###") {
#this is a nice way to send to the end result of proper log ins
header("Refresh: 1; url=admin.php");
} else {
#if info was not correct, then go back to log in script here
	require(login.php);
}
?>
Post Reply