I have went trough a nightmare to get this code because I am really pure on PHP and now I have a small question.
Code: Select all
<form name="loginf" action="../test/loginck.php" method="post">
<tr>
<td height="" style="padding-top:5px;padding-bottom:5px;"><table width="151" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><span id="login"><span>Login</span></span></td>
</tr>
<tr>
<td align="center" class="lrbg" width="151"><table width="141" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div class="text">Username:</div>
<input name="userid" type="text" class="text" size="22" ></td>
</tr>
<tr>
<td><div class="text">Password:</div>
<input name="password" type="password" class="text" size="22" ></td>
</tr>
<tr>
<td align="center" style="padding-top:3px;padding-bottom:3px;"><table width="0" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span id="login_form_tp"></span></td>
</tr>
<tr>
<td class="login_form_bg" align="center"><a href="javascript:document.forms['loginf'].submit();" class="link">Log in</a></td>
</tr>
<tr>
<td><span id="login_form_bt"></span></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" style="padding-top:3px;padding-bottom:3px;"><table width="0" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span id="login_form_tp"></span></td>
</tr>
<tr>
<td class="login_form_bg" align="center"><a href="javascript:alert('Registration is not allowed yet!')" class="link">Register</a></td>
</tr>
<tr>
<td><span id="login_form_bt"></span></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><span id="lr_bt"></span></td>
</tr>
</table></td>
</tr>
</form>Code: Select all
<?
include "include/session.php";
$dbservertype='mysql';
$servername='localhost';
//
$dbusername='';
$dbpassword='';
//
$dbname='fans_db';
//
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Couldn't connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("Couldn't find database.".mysql_error());
}
//
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Test log in</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);
if($rec=mysql_fetch_array(mysql_query("SELECT * FROM plus_signup WHERE userid='$userid' AND password = '$password'"))){
if(($rec['userid']==$userid)&&($rec['password']==$password)){
include "include/newsession.php";
echo "<p class=data> <center>Successfully,Logged in<br><br><a href='logout.php'> Log OUT </a><br><br><a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";
print "<script>";
print " self.location='welcome.php';";
print "</script>";
}
}
else {
session_unset();
echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct Userid and Password and Try <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
}
?>
</body>
</html>
I haven't created the database yet, but the question is not about that.
I want to show these messages (Wrong Login... Successfully,Logged...) on .html file, but I think they won't show there because there is no return script or something.
What should I do to create clear log in page where on log in page under the log in form would show those messages (wrong login or password) and after successful login the log in window form don't show? I want it on html file but I can move to .php too.
Instruct me please what and how to do?