 |
| 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
|
|
|
|

September 11th, 2003, 04:12 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Getting Data from the client
Hi,
Ok I'm the most beginner in PHP but here is something I really don't understand. I'm following each step in the book (Beginning PHP 4) in the chapter 3 and I'm not able to find what I'm doing wrong - even when I took the source code from wrox web site nothing more happens.
When I'm doing the first Try It Out (p.76) from using text fields (Who is your favorite author? -text box- and a submit button. When I click on submit I got nothing on the other side except Your favorite author is: I don't have here the name I put before. The fact is that the author name I put passed as a query string but cannot be show.
And Yes I have double checked my spelling and even if I took (like I said) the source code from wrox it's doing the same thing.
what's the problem with this?
Did somebody can help me please...??
Thanks,
-Wander-
|
|

September 11th, 2003, 06:54 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'll also add something here (as always... I can't shut the hell up!)
There are two main methods for a client (user) to send data to the web server (your PHP application): GET and POST. POST data can only be submitted via a form who's method is explicitly set to POST. GET data comes in as a list of parameters in the URL.
A form submits its data via GET by default. You can also specify a form's method as GET. When the user submits a get-method form, his/her browser simply creates the parameter string from the form input fields and appends it to the URL the form submits to (it's "action" attribute). Therefore, even when submitted by a form, GET parameters always come to the server via the URL.
This means that you can easily determine which superglobal array to use when looking for your user input. If you're using hyperlinks or a form with method="get" (or no method specified at all), use $_GET. If you're using a form with method="post", use $_POST.
Take care,
Nik
http://www.bigaction.org/
|
|

September 16th, 2003, 08:05 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Okay, after all those text I read I'm not getting it. I still don't understand what's wrong with my code:
Here's a example of it (don't laugh it's a pretty tiny code...)
text.php
<HTML>
<HEAD></HEAD>
<BODY>
Your favorite author is:
<?php
echo $_GET['Author'];
?>
</BODY>
</HTML>
text.html
<HTML>
<HEAD></HEAD>
<BODY>
<FORM METHOD=GET ACTION="text.php">
Who is your favourite author?
<INPUT NAME="Author" TYPE="TEXT">
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
Maybe I'm to tired or what, but I was thinking that with regiter_globals=off the only thing I have now to do is put $_GET (or other method) before but I think it's not.
Thanks!!!
-Wander-
|
|

September 17th, 2003, 12:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That code should work just fine! What are you seeing happen?
Is PHP installed properly? That is, can you see output from this script?: <?php phpinfo(); ?>
Does text.php exist in the same directory as text.html?
Take care,
Nik
http://www.bigaction.org/
|
|

September 25th, 2003, 12:19 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Okay, I think my problem is IIS configuration. I tried many things but nothing yet.
If somebody has a hint for me.... then let's go!!!
Tks,
Wander
WinXP Pro (w/ latest updates)
P4 1.6 Ghz
PHP 4.3.2
MySQL 3
IIS
|
|

September 25th, 2003, 11:17 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You still didn't answer -- what do you see when you run a simple phpinfo() script?
Take care,
Nik
http://www.bigaction.org/
|
|

September 26th, 2003, 03:40 PM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
Like you, I am new to PHP ..ran the same same program as you and had the similar problem.
I created a script testPhp.php
added the line:
<?php phpinfo(); ?>
saved and ran from the browser. This was successful. It showed all the configuration details.
According to it, the php.ini file resides in c:\WINDOWS.
I edited php.ini, searched for string 'register_globals'
The value was set to Off. I changed it On, saved it.
The script then worked. Did print the Author I entered.
Not sure why the variable Author have to be global. I need to do more thinking
James S
|
|

September 26th, 2003, 03:49 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Hi James,
Turning on register_globals is a bad idea.
We've discussed this topic quite a bit already, so rather than reiterate the point of the directive's off value I'll point you to some url's in the archive that discus this topic.
Start with Nik's FAQ:
http://p2p.wrox.com/archive/beginnin...2002-11/17.asp
And see the many other threads on this topic by doing a google search on p2p forums:
http://www.google.com/search?q=regis...e:p2p.wrox.com
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
|
|

September 26th, 2003, 03:57 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
And actually now that I see this thread it already has many of these URL's posted to it! Read the PHP manual pages that I posted in an earlier reply!
And Nik's brief overview of how register_globals = off works- also in this thread!
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
|
|
 |