Jump to content

This is my login script, but the message that shows up for invalid input no work


ted_chou12

Recommended Posts

[code]
<?php
ob_start();
session_start();

require_once ("functions.php");

$returnurl = urlencode(isset($_GET["returnurl"])?$_GET["returnurl"]:"");
if($returnurl == "")
$returnurl = urlencode(isset($_POST["returnurl"])?$_POST["returnurl"]:"");

$do = isset($_GET["do"])?$_GET["do"]:"";

$do = strtolower($do);

switch($do)
{
case "":
if (checkLoggedin())
{include("usernav.php");?>
<h3>User Logged In</h3>
<p>This is the members only area.</p>
<?php } else {?>

<a name="User Panel"></a>
<h1>User Panel</h1>
<h3>User Login</h3>
<form name="login" action="login.php?do=login" method="POST" onsubmit="return aValidator();">
<input type="hidden" name="returnurl" value="<?$returnurl?>">
<table cellPadding=3 width=225 border=1>
<tr>
<td colSpan=2>
<center>
<p><b>Members-Only Area!</b></font></p>
</center></td></tr>
<tr>
<td align=center width=70>Username:</td>
<td><input type="text" name="username"></td></tr>
<tr>
<td align=center width=70>Password:</td>
<td><input type="password" name="password"></font></td></tr>
<tr>
<td align=middle colspan=2>
<input type="submit" name="submit" value="Login"></td></tr>
<td align=middle colSpan=2>
<input type="checkbox" name="remme" value="on">&nbsp;Remember me for the next time I visit</td>
</form></table></td>
<?php
}
break;
case "login":
$username = isset($_POST["username"])?$_POST["username"]:"";
$password = isset($_POST["password"])?$_POST["password"]:"";

if ($username=="" or $password=="" )
{
echo "<h1>Username or password is blank</h1>";//this does not show when the input(s) are blank
clearsessionscookies();
header("location: index.php?returnurl=$returnurl");
}
else
{
if(confirmuser($username,$password))
{
createsessions($username,$password);
if ($returnurl<>"")
header("location: $returnurl");
else
{
header("Location: index.php");
}
}
else
{
echo "<h1>Invalid Username and/Or password</h1>";//this message does not show when the user login invalid
clearsessionscookies();
header("location: index.php?returnurl=$returnurl");
}
}
break;
case "logout":
clearsessionscookies();
header("location: index.php");
break;
}
?>
[/code]
What maybe the case, could anyone help me with this?
Thanks Ted.
Link to comment
Share on other sites

  • 5 years later...
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.