note 90691 added to language.variables.external

From: Date: Tue, 05 May 2009 06:46:15 +0000
Subject: note 90691 added to language.variables.external
Groups: php.notes 
Request: Send a blank email to php-notes+get-154212@lists.php.net to get a copy of this message
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">&nbsp;</th> <td><input type="submit" name= "sublogin" value="Log In" /></td> </tr> </table> <p>&nbsp;</p> </form> <? displayLogin($_POST ['user'], $_POST ['pass']); ?> </body> </html> I would appreciate any help anyone can extend. THANKS ^____^ ---- Server IP: 69.147.83.197 Probable Submitter: 125.60.175.139 ---- Manual Page -- http://www.php.net/manual/en/language.variables.external.php Edit -- https://master.php.net/note/edit/90691 Del: integrated -- https://master.php.net/note/delete/90691/integrated Del: useless -- https://master.php.net/note/delete/90691/useless Del: bad code -- https://master.php.net/note/delete/90691/bad+code Del: spam -- https://master.php.net/note/delete/90691/spam Del: non-english -- https://master.php.net/note/delete/90691/non-english Del: in docs -- https://master.php.net/note/delete/90691/in+docs Del: other reasons-- https://master.php.net/note/delete/90691 Reject -- https://master.php.net/note/reject/90691 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154212) next »