Re: Again, and Again, and AGAIN!
| From: | Jason Wong | Date: | Sun, 17 Mar 2002 05:14:31 +0000 |
| Subject: | Re: Again, and Again, and AGAIN! | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88803@lists.php.net to get a copy of this message | ||
On Sunday 17 March 2002 12:12, Dr. Shim wrote:
> I'm using PHP 4.1.1 (for Windows). Here is *all* of my code.
>
> <html>
> <head>
> <title>Administrative Log-In Page</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> </head>
>
> <body bgcolor="#FFFFFF">
> Please enter your username and password below in the fields below.
> <form method="post" action="<?php echo $PHP_SELF; ?>">
> Username:
> <input type="text" name="username" maxlength="255"
> value="<?php echo
> $HTTP_POST_VARS['username']; ?>">
You're using 4.1.1, $HTTP_POST_VARS{} has been replaced by $_POST[] (see
changelog/history/php.ini for details).
> <br>
> Password:
> <input type="text" name="password" maxlength="8"
> value="<? echo
> $HTTP_POST_VARS['password']; ?>">
> <br>
> <input type="submit" name="login" value="Log In">
> <br>
> <br>
> </form>
> <?php
> if (isset($login)) {
> insert();
> echo $login;
> }
>
> function insert() {
> $db = odbc_connect('IdentDatabase', 'root', '');
>
> if(!$db) {
> echo "An error has occured. Please <a
>
> href=\"mailto:drshim@alienmelon.com\">e-mail</a>
> the text below to
> me.<br><br>~~~~~~~<br>$PHP_ERROR<br>$db<br>~~~~~~~";
> }
>
> $SQLQuery = "SELECT fldID FROM tblUsers WHERE fldUsername = '$username'
> AND fldPassword = '$password'";
If register_globals is not ON, then $username & $password will not have been
defined. You have to reference them as $_POST['username']. But as you're
referencing an array from inside a double-quoted string then just
$_POST[username] will do:
$SQLQuery = "SELECT fldID FROM tblUsers
WHERE fldUsername = '$_POST[$username]'
AND fldPassword = '$_POST[$password]'";
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
You'd like to do it instantaneously, but that's too slow.
*/