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 September 11th, 2003, 04:12 PM
Registered User
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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-


 
Old September 11th, 2003, 05:23 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Hi wander,
Your question relates to the register_globals directive set in php.ini. This directive was changed to tighten PHP security and has been set to off by default since php 4.1.

You are also likely to experience problems with the error_reporting directive set to E_ALL. Which produces Notice level errors in addition to parse, fatal, and other errors.

These subjects have also been addressed exhaustively on these forums.

  http://p2p.wrox.com/archive/beginnin...2002-11/17.asp
  http://p2p.wrox.com/archive/beginnin...2003-03/14.asp
  http://p2p.wrox.com/topic.asp?TOPIC_ID=3935

  http://www.php.net/security
  http://www.php.net/security.registerglobals
  http://www.php.net/security.variables
  http://us4.php.net/manual/en/languag...predefined.php
  http://www.php.net/isset
  http://www.php.net/empty

Have a look at these urls which explain further each of these directives. If you still have questions, just let us know and someone will walk you through it.

: )
Rich




:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old September 11th, 2003, 06:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Code:
http://some.server.com/some_page.php...ice=wonderland
                                     \----- GET params -----/
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/
 
Old September 16th, 2003, 08:05 PM
Registered User
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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-

 
Old September 17th, 2003, 12:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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/
 
Old September 25th, 2003, 12:19 PM
Registered User
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old September 25th, 2003, 11:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You still didn't answer -- what do you see when you run a simple phpinfo() script?


Take care,

Nik
http://www.bigaction.org/
 
Old September 26th, 2003, 03:40 PM
Registered User
 
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old September 26th, 2003, 03:49 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
:::::::::::::::::::::::::::::::::
 
Old September 26th, 2003, 03:57 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass data from Client to server script pushpa Classic ASP Basics 8 March 11th, 2007 04:30 AM
client side sorting and paging in data grid prankur ASP.NET 1.0 and 1.1 Basics 1 February 3rd, 2006 12:05 PM
client side sorting and paging in data grid prankur ASP.NET 1.0 and 1.1 Professional 1 February 3rd, 2006 12:00 PM
storing data client side Anjali VBScript 3 September 3rd, 2004 05:24 PM
manipulate data returned using client script alyeng2000 Classic ASP Databases 5 December 9th, 2003 01:39 PM





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