Reply to Re: POST, GET and variables ?

Your name:

Reply:


Posted by Kimmo Laine on 02/15/07 20:00

dirk kirjoitti:
> Kimmo Laine wrote:
>
>> Please post some code. The form itself would be quite helpful. What is
>> the output of <?php print_r($_POST); ?>
>>
> Thanks for your reply. If both input-text-fields were filled in, the
> output of print_r($_POST) is : Array ( )
> If only one input-text-field is filled in, output is : Array ( [email] =>
> mail [pass] => ) or Array ( [email] => [pass] => password )

In both cases it should also contain the submit button, I'm guessing it
defaults to "submit" => "submit" if no values are provided for name and
value.

> Here is the code :
>
> <?php
> $dbh=mysql_connect("localhost","user","pass") or die("Can't connect to
> db!");
> mysql_select_db("calendar") or die("Can't select db!");
> session_start();
> if (!$_SESSION["Login"]) {
> if ($_POST['email'] AND $_POST['pass']) {
> $Email=$_POST['email'];
> $Pass=$_POST['pass'];
> $mydb=mysql_query("SELECT ID from admin WHERE Email='$Email'
> and Pass= MD5('$Pass') LIMIT 1");
> if ($data=mysql_fetch_array($mydb)) {
> $_SESSION["Login"]=$data["ID"];
> }
> $me=$_SERVER['PHP_SELF'];
> header("Location: $me");
> exit;

Should the email and password match and the code reaches this point, the
post data is lost. Ie. if the login is successful, you'll never see the
result of the real print_r($_POST) because of the redirection. Humour me
and run the test case so that a) the login crendentials you input are
wrong so you don't log in and b) comment the header and exit lines so
that you are not redirected to another page after successfull login.
Then see the output.

> }
> print <<<EOL
> <head>
> <title>Admin Console</title>
> </head>
> <body>
>
> <h1>admin system</h1>
> <form action=
> EOL;
> echo $_SERVER["PHP_SELF"];
> print <<<EOL
> method=post>
> <p>Email<input type=text name=email></p>
> <p> Pass<input type=password name=pass></p>
> <input type=submit>
> </form></body></html>
> EOL;
> die();
>
> }
> ?>

Of course it never hurts to eliminate all other possible causes for
failure, until you've narrowed it down to the real thing. Hence I
suggest you clean the code, insert the quotemarks in right places and so on.

Missing submit from $_POST is quite mysterious. The empty array() can be
explained if the page is redirected. The test case should be the kind
where there is absolutely nothing but a form and print_r to make sure
there isn't anything else causing the data to be lost.

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация