Re: Form variable to PHP script problems
| From: | Justin French | Date: | Mon, 05 Aug 2002 05:04:00 +0000 |
| Subject: | Re: Form variable to PHP script problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111140@lists.php.net to get a copy of this message | ||
Search the archives for "register globals"... this has been discussed in
around 2000+ emails to the group.
In short, include this line at the top of the form processing script:
<?
$nome = $_POST['nome'];
$senha = $_POST['senha'];
?>
... or refer to the POSTed (form) variables as $_POST['variable_name']
rather than $variable_name.
Justin French
on 05/08/02 9:29 AM, Renato B. Miranda (renato_bm@yahoo.com.br) wrote:
> Hello !
> I´m developing a dinamic site and I started to use PHP, MySQL and
> Apache.
> The things are going well, I´m already using database, inserting,
> everything ....
> But when I try to pass some variables from a Form to a PHP isn´t working
> !
> Somebody could help me ?
> Here is my code .....
>
> HTML
> <html>
> <p align="center"><font face="Arial Black"
> size="5">Banco de Dados
> Cesop</font></p>
> <p align="center"> </p>
> <form action="validaUsuario.php" method="post" >
> <p align="center">Usuário: <input type="text"
> NAME="nome"
> size="20"></p>
> <p align="center">Senha: <input
> type="password" NAME="senha" size="20"></p>
> <p align="center"><input type="submit" value="Submeter"
> name="B1"></p>
>
> </form>
> </body>
> </html>
>
> PHP
> <?
> $connection = mysql_connect("localhost", "renato", "ren9ato8")
> or die ("Unable to connect to server.");
> $db = mysql_select_db("cesop", $connection)
> or die ("Unable to select database.");
>
> echo $senha;
>
> $sql = "SELECT nome
> FROM users
> WHERE nome='$nome' and password='$senha'";
> $result = mysql_query($sql, $connection)
> or die ("Unable to get results.");
> $num = mysql_numrows($result)
> or die ("You're not authorized to be here. If you feel you have
> recieved this
> message in error, please contact the <a
>
> href=\"mailto:tyler.longren@midiowa.net\">webmaster</a>");
>
> if ($num == 1) {
> echo "<p>You can be here<br>";
> echo "Your username is $nome</p>";
> }
> ?>
>
> Thanks !
>