Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
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
 
Old January 26th, 2005, 03:30 AM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


 
Old January 26th, 2005, 08:25 AM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old January 26th, 2005, 12:41 PM
Authorized User
 
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru
Default

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
 
Old January 26th, 2005, 03:02 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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?
 
Old January 27th, 2005, 02:31 AM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old January 27th, 2005, 11:59 AM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old January 29th, 2005, 01:52 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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?
 
Old January 31st, 2005, 06:04 PM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to garrettw
Default

Snib, why do you say it's generally not a good idea to use $_REQUEST?

 
Old January 31st, 2005, 09:29 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

$_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?
 
Old February 1st, 2005, 07:07 PM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to garrettw
Default

so what is the $_FILES var? don't know about that.






Similar Threads
Thread Thread Starter Forum Replies Last Post
isset($_POST) summi_beniwal Beginning PHP 1 June 21st, 2008 07:13 AM
$_POST PROBLEM karlirvin PHP How-To 1 December 16th, 2005 03:14 AM
Request.QueryString("varName") record selection??? bubberz BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 June 27th, 2005 12:34 PM
Getting nothing from $_POST['varName']; Kalisan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 January 26th, 2005 03:00 PM
setting $_POST donh BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 9 January 20th, 2004 01:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.