Page 1 of 1

$_POST[] not working 4.0

Posted: Tue Feb 04, 2003 7:19 am
by qads
hi,

Code: Select all

<?php
<?php
include("db.inc");
if(IsSet($_POST['enter']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$password = MD5($password);
$sql = "SELECT * FROM admin WHERE username='$username' AND password='$password'";
$results = mysql_query($sql);
$count = mysql_num_rows($results);

if ($count == 1)
{
session_start();
$_SESSION['admin'] = $username;
header("Location: main.php?page=home");
}
//show error if the user is not in the DB
else
{
echo("Login Failed, please try agian...");
}
}
?>
<form method='POST' action='login.php'>
  <table border='0' width='100%'>
    <tr>
      <td width='50%' align='right'><font color='#000000'><b>Username:</b></font></td>
      <td width='50%'><input type='text' name='username' size='15'></td>
    </tr>
    <tr>
      <td width='50%' align='right'><font color='#000000'><b>Password:</b></font></td>
      <td width='50%'><input type='password' name='password' size='15'></td>
    </tr>
  </table>
  <p><input type='hidden' name='enter' value='1'><input type='submit' value='Login' name='Login'></p>
</form>
?>
$_POST[enter] does't work on php version 4.0 but works fine on 4.2.3, why?

thanks for your time
- Qads

Posted: Tue Feb 04, 2003 7:24 am
by twigletmac
PHP version 4.0.6 or lower does not have the superglobals, $_POST, $_GET, $_SESSION et. al, you have to use the $HTTP_xxx_VARS arrays instead:
http://www.php.net/manual/en/reserved.variables.php

Mac

Posted: Tue Feb 04, 2003 7:33 am
by qads
i tried searching for it before but could't find it :/.

thanks