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!
<?php
// simple login script
// filename: login.php
$form = '
Simple Login Form<br>
<form action=”login.php” method=”post”>
<input type=”text” name=”username”>
<input type=”password” name=”password”>
<input type=”submit” name=”submit” value=”submit this”>
</form>
';
if(isset($_POST['submit'])){
$hm = authenticate($_POST['username'], $_POST['password']);
$hm2 = mysql_num_rows($hm);
if($hm2 > 0){
echo 'wat';
}else{
echo 'username / password not valid<br>';
echo $form;
}
}else{
echo $form;
}
function authenticate($user, $pass){
$user = str_replace(' ', '', $user); //remove spaces
$pass = str_replace(' ', '', $pass); //remove spaces
$user = str_replace('%20″', '', $user); //remove escaped spaces
$pass = str_replace('%20″', '', $pass); //remove escaped spaces
// add slashes to escape things like quotes and apostrophes
// because they can be used to hijack SQL statements!
$user = addslashes($user); //remove spaces from username
$pass = addslashes($pass); //remove spaces from password
// the function md5 creates a unique 32 character string,
$pass = md5($pass);
$request = 'SELECT * FROM users WHERE password=’$pass’ AND email="$user"';
// Pass the request to the mysql connection,
$results = query_db($request);
// if mysql returns any number of rows great than 0 there is a match
return $results;
function query_db($query)
{
include("config.php");
}
[b][u]?>[/b][/u]
I get unexpected $end in line 81
Line 81 is bolded and underlined
<?php
// simple login script
// filename: login.php
$form = '
Simple Login Form<br>
<form action=”login.php” method=”post”>
<input type=”text” name=”username”>
<input type=”password” name=”password”>
<input type=”submit” name=”submit” value=”submit this”>
</form>
';
if(isset($_POST['submit'])){
$hm = authenticate($_POST['username'], $_POST['password']);
$hm2 = mysql_num_rows($hm);
if($hm2 > 0){
echo 'wat';
}else{
echo 'username / password not valid<br>';
echo $form;
}
}else{
echo $form;
}
function authenticate($user, $pass){
$user = str_replace(' ', '', $user); //remove spaces
$pass = str_replace(' ', '', $pass); //remove spaces
$user = str_replace('%20″', '', $user); //remove escaped spaces
$pass = str_replace('%20″', '', $pass); //remove escaped spaces
// add slashes to escape things like quotes and apostrophes
// because they can be used to hijack SQL statements!
$user = addslashes($user); //remove spaces from username
$pass = addslashes($pass); //remove spaces from password
// the function md5 creates a unique 32 character string,
$pass = md5($pass);
$request = 'SELECT * FROM users WHERE password=’$pass’ AND email="$user"';
// Pass the request to the mysql connection,
$results = query_db($request);
// if mysql returns any number of rows great than 0 there is a match
return $results;
} // Added by [url=http://phpguruji.blogspot.com]Sujith[/url]
function query_db($query)
{
include("config.php");
}
?>
Im horrible with the PHP mySQL functions and etc.
When I hit login it goes to a 404. Could anyone please tell me where it shows the page that you will be directed to when you hit login