473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

POST, GET and variables ?

Hello,
As beginner, I'm a bit confused by passing 2 variables using a html-form
with method=POST. If passing one of them, it works ; if passing both
together, nope. At least when I reload the same page by using
$_SERVER["PHP_SELF"] in an included file (inc.php) it doesn't work.
Referring to another "page.php" is succesfull. Also passing both variables
with the GET-method works. Can somebody help me please ?
Thank you,
Dirk.
Feb 15 '07 #1
3 1788
dirk kirjoitti:
Hello,
As beginner, I'm a bit confused by passing 2 variables using a html-form
with method=POST. If passing one of them, it works ; if passing both
together, nope. At least when I reload the same page by using
$_SERVER["PHP_SELF"] in an included file (inc.php) it doesn't work.
Referring to another "page.php" is succesfull. Also passing both variables
with the GET-method works. Can somebody help me please ?
Thank you,
Dirk.
Please post some code. The form itself would be quite helpful. What is
the output of <?php print_r($_POST); ?>

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Feb 15 '07 #2
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 )
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;
}
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>
<pPass<input type=password name=pass></p>
<input type=submit>
</form></body></html>
EOL;
die();

}
?>
Feb 15 '07 #3
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>
<pPass<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ö
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Feb 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert | last post by:
Hello, Can anyone help with this? On my online order form, I need to send a few variables to my credit-card processor. These variables are for non-secure customer comments, and will be sent...
2
by: Robert | last post by:
Can anyone do this? Using PHP, I want to POST or GET some variables to a second php page. This, I already know how to do. However, on the second php page, I want to use a simple, standard HTML...
5
by: Michael Foord | last post by:
I'm receiving POST data to a CGI, which I'd like to forward to another CGI using urllib2. I have two options - 1) Parse the data using cgi.FieldStorage() and then rebuild the POST request...
2
by: Asp Help | last post by:
I'm working on a ASP applicatition to create Windows 2000 users. Because I don't want everybody to have access to the site I've changed te security in IIS 5.0 which runs on a windows 2000 Sp4...
5
by: Kit | last post by:
Hi there, I am recoding a website, and I want to add a generic footer to each page, using an included file with PHP snippets. Part of that footer would be a link to validate the page using the...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
4
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form...
3
by: Vic Spainhower | last post by:
Hello, I have an HTML table that is being constructed from a MySQL table and displays a form that includes a check box on 1 of the fields on the form for each record. I have included in this PHP...
5
Atli
by: Atli | last post by:
Hi everybody. After years of C# and PHP, I'm finally returning to Java. My goal is to create a Java program capable of sending images to a PHP Photo Album on my web server. Right now, however,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.