|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
January 26th, 2005, 03:30 AM
|
Registered User
|
|
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Getting nothing from $_POST['varName'];
Hi there,
I'm trying to set up a simple login page. The script i've written works fine on my server but not on my clients server (hostsave.com - PHP is installed). Basically I get nothing when I check;
$u = $_POST['username'];
$p = $_POST['password'];
echo $u;
echo $p;
So the variables from the login page are not being passed to the verify page. I've also tried it with GET. Has anyone encountered this problem before?
Cheers,
//Kalisan
|
January 26th, 2005, 08:25 AM
|
Authorized User
|
|
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
do a
<?php phpinfo(); ?>
to make sure php is installed.
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance
|
January 26th, 2005, 12:41 PM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You may have subitted your form by GET method. So you can try
$u=$_GET['username'];
or you can try
$u=$_REQUEST['username'];
(this line will set values sent by either POST or GET)
Best Regard:
Md. Zakir Hossain (Raju)
www.rubd.net
www.xenex.rubd.net
www.forum.rubd.net
|
January 26th, 2005, 03:02 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Rather than working around the problem by using _REQUEST, I suggest you solve it.
1) Make sure PHP is installed using Gotaka4's method
2) Make sure the form method is POST and the code asks for _POST
It is generally not a good idea to use _REQUEST.
-Snib - http://www.snibworks.com
Where will you be in 100 years?
|
January 27th, 2005, 02:31 AM
|
Registered User
|
|
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the advice guys. I've just been notified by the hosting company that their version of PHP does not support super globals such as $_GLOBALS, $_GET, $_POST, $_SESSION! :(
I'm new to PHP and have no idea how to achieve the above without these variables - any pointers?
Cheers,
// Kalisan
|
January 27th, 2005, 11:59 AM
|
Authorized User
|
|
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hmm....that sucks.
I wonder what ancient PHP they have installed....still do a phpinfo and get some info on the php version they have.
to get around it, doing javascript and php you can acheive the same thing...by getting form values using javascript ( assuming you can do this - not good at javascript), and then entering them in a database using php (mysql), and on the next page, retrieving them from database using php again.........quite a painful process.
tell your hosting company to upgrade their php...it will only take them a few minutes?
----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
|
January 29th, 2005, 01:52 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Try $HTTP_POST_VARS then.. and follow Gotaka's suggestion, find out what PHP they have.
And might I recommend switching hosts
-Snib - http://www.snibworks.com
Where will you be in 100 years?
|
January 31st, 2005, 06:04 PM
|
Registered User
|
|
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Snib, why do you say it's generally not a good idea to use $_REQUEST?
|
January 31st, 2005, 09:29 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
$_REQUEST is made of three superglobals combined: $_GET, $_POST and $_FILES. There are sometimes times that you need to access a $_GET index that has the same index name as a $_POST index, so therefore you can't access it.
Quote:
quote:Quoted from http://www.phpdiscuss.com/article.ph...up=php.general
Be carfull with this super var. This var is a merge of the GET, POST and
FILES, and so only 1 index can only exists. If you have an index in the POST
field called 'test' and also and index calles test in the FILES or GET var,
than only one index of them is avaible and the other are gone....
I recommend to use the GET, POST and FILES var instead of the REQUEST var..
|
hth,
-Snib - http://www.snibworks.com
Where will you be in 100 years?
|
February 1st, 2005, 07:07 PM
|
Registered User
|
|
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
so what is the $_FILES var? don't know about that.
|
|
|