Jump to content

defining a variable


merylvingien

Recommended Posts

What the hell am i missing here??

 

Trying to set the $output so if there are any errors it will display a message.

If no email or password is entered the $output is echoed fine

 

But if the wrong email or password is entered the $ouptut is not echoed at all???

 

if (loggedin()){
header ("Location: index.php");
exit();
}
if (isset ($_POST['login']))
{
$email= $_POST['email'];
$password= $_POST['password'];
if (isset ($_POST['rememberme'])) {$rememberme= $_POST['rememberme'];}
if (isset($rememberme)) {$rememberme= "on";} else {$rememberme= "off";}
if (empty($email)) {$output= "<span class='error'>Please enter a username or password</span>";}
if (empty($password)) {$output= "<span class='error'>Please enter a username or password</span>";}
if ($email&&$password)
{
$login= mysql_query ("SELECT * FROM user WHERE email='$email'");
while ($row= mysql_fetch_assoc($login))
{
$passwordcheck = $row['password'];
if (md5($password)==$passwordcheck)
$loginok = true;
else 
$loginok = false;

if ($loginok==true)
{
$uniquelogon = "{$row['uniqlogon1']}";
if ($rememberme=="on"){
setcookie("uniquelogon", $uniquelogon, time()+2628000);}
else
if ($rememberme=="off"){
session_start();
$_SESSION['uniquelogon'] = "$uniquelogon";}
header ("Location: index.php");
exit();
}
else
echo "<span class='error'>Your Email or Password do not match our records</span>";
}
}
}

<?php if (!empty($output)) {echo $output;} ?>
<form action"login.php" method="POST">
<p>Email:<br>
<input type="text" name="email">
</p>
<p>Password:<br>
<input id="pwd" type="password" class="required lock pad" watermark="{html:'Password',cls:'pad empty'}" name="password">
</p>
<p>
<input type="checkbox" name="rememberme">
Remember Me!<br>
</p>
<input type="submit" name="login" value="Log In">
</form>

 

Ive used all my special powers trying to get this to work, but i am missing something...

Link to comment
https://forums.phpfreaks.com/topic/227888-defining-a-variable/
Share on other sites

if ($rememberme=="off"){
session_start();
$_SESSION['uniquelogon'] = "$uniquelogon";}
header ("Location: index.php");
exit();
}
else
$output= '<span class="error">argh</span>';
}
}
}

 

 

Like that you mean? which is what AbraCadaver suggested, which i have already tried.

Ive tried all sorts of different combinations but nothing i do will display!

 

I cant understand where i am going wrong here.

Link to comment
https://forums.phpfreaks.com/topic/227888-defining-a-variable/#findComment-1175127
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.