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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.