$_POST[] not working 4.0

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

$_POST[] not working 4.0

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i tried searching for it before but could't find it :/.

thanks
Post Reply