Skip to content Skip to sidebar Skip to footer

Action Script For Login Form Not Working

having problems understanding why my script to login will not work, so its a simple login script that checks the users and fields as expected yet when it does the logic it does not

Solution 1:

You misspelled $_SERVER variable - there is not such thing like $SERVER

EDIT

login_tools.php

functionvalidate($dbc, $email = ',$pwd = ')

should be:

functionvalidate($dbc, $email = '' , $pwd = '')

next:

$e = mysqli_real_escape_string($dbc, trim($pwd));

should be:

$p = mysqli_real_escape_string($dbc, trim($pwd));

and return statement move after if statement:

if (empty($errors)) {
    ...
}

returnarray(false, $errors);

I hope that you're playing around with PHP or something, beacuse this is really bad code. But you know that, right?

Solution 2:

Ok so I found a new script to see if I can see if it its a problem with the database, table or the script - Heres the new script:

Login.php

<h1>Login</h1><formaction="login_action.php"method="POST"><p>

Email Address: <inputtype="text"name="email" /></p><p>

Password: <inputtype="password"name="pass" /></p><p><inputtype="submit"value="login"  /></p></form>

checklogin.php

<?phpinclude ('connect_db.php');


$myemail=$_POST['email'];
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail about MySQL injection)$myemail = stripslashes($myemail);
$mypassword = stripslashes($mypassword);
$myemail = mysql_real_escape_string($myemail);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT user_id, email, first_name, last_name FROM users WHERE email='$myemail' and pass='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("email");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo"Wrong email or Password";
}

?>

login_success.php

<?php
session_start();
if(!session_is_registered(email)){
header("location:login.php");
}
?><html><body>
Login Successful
</body></html>

The error I get now is the email or password is wrong? I know that it isnt...

Post a Comment for "Action Script For Login Form Not Working"