note 90691 rejected from language.variables.external by thiago
| From: | thiago@php.net | Date: | Tue, 05 May 2009 12:27:00 +0000 |
| Subject: | note 90691 rejected from language.variables.external by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154223@lists.php.net to get a copy of this message | ||
Note Submitter: lisl dot cammile at gmail dot com
----
i'm new in using PHP,. I'm trying to compare the $_POST ['username'] with this
variable $user which have the value of the allowed user to access the webpage. I made the user and
password statict since there's only one user.
here's the code for the log.php, i really am not sure if i did it right:
<?
$user_Stat ="admin";
$Pass_Stat ="pass";
?>
<?
function displayLogin($username, $password)
{
{ if(isset($_POST['sublogin']))
{
/* Check that all fields were typed in */
if(!$_POST['user'] || !$_POST['pass'])
{
die('You didn\'t fill in a required field.');
}
/* check length */
$_POST['user'] = trim($_POST['user']);
if(strlen($_POST['user']) > 30)
{
die("Sorry, the username is longer than 30 characters, please shorten it.");
}
if( $_POST['user'] == $user_Stat && $_POST['pass']== $pass_Stat )
{
header("Location: http://localhost/today.php");
}
else
{
echo ("Invalid Password or Username");
?>
<?
}
}
}
}
?>
the form is in main.php, here's the code:
<?
/* Include Files *********************/
include("log.php");
/*************************************/
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>LOG IN ADMIN</title>
<style type="text/css">
<!--
body {
background-color: #000066;
}
.style1 {color: #FFFFFF}
.style3 {font-weight: bold; font-size: xx-large; color: #000066;}
-->
</style></head>
<body>
<form action="" method="post">
<p align="left" class="style1"><strong>
AUTHENTICATION</strong></p>
<table width="275" border="0" title="Authentication">
<tr>
<th width="73" scope="row"><span class="style1">
Username:</span></th>
<td width="186"><label>
<input type="text" name="user" />
</label></td>
</tr>
<tr>
<th scope="row"><span
class="style1">Password:</span></th>
<td><input type="password" name="pass" /></td>
</tr>
<tr>
<th scope="row"> </th>
<td><input type="submit" name= "sublogin" value="Log
In" /></td>
</tr>
</table>
<p> </p>
</form>
<? displayLogin($_POST ['user'], $_POST ['pass']);
?>
</body>
</html>
I would appreciate any help anyone can extend.
THANKS ^____^