Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 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 May 15th, 2004, 07:50 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch3, P.76 - text.html/text.php not working

I have gone over my code a dozen times and I get the same error with my code and the code supplied from the Wrox site. The error is:

Code:
Your favorite author is: 
Notice: Undefined variable: Author in C:\Program Files\Apache Group\Apache2\htdocs\wrox_examples\ch03\text.php on line 6
Here is the form page, text.html:
Code:
<HTML>
<HEAD></HEAD>
<BODY>
<FORM METHOD=POST ACTION="text.php">
Who is your favorite author?
<INPUT NAME="Author" TYPE="TEXT">
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
and text.php
Code:
<HTML>
<HEAD></HEAD>
<BODY>
Your favorite author is:
<?php
echo $Author;
?>
</BODY>
</HTML>
I'm running:

Apache 2.0.49
PHP 4.3.6
on Windows 2000 Server

Any ideas?

TIA

 
Old May 15th, 2004, 07:57 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found a topic about turning register_globals to "On" and I did, now this works. I've also read this should be turned off in a production environment. How is this going to effect the code that I am learning in this book when I start creating my own applications?

 
Old May 15th, 2004, 08:06 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Iain,

register_globals just automatically sets all superglobal variables (i.e. $_POST and $_GET) to normal variables like $name and $author.

The downside:

Security

Take this page, for instance, that you want no one but those logged in to access. register_globals is on and the session variable is $name.

<?php

session_start();

if($name)echo "Welcome!";

else header("Location: error.php");

?>


Say this page is index.php. If someone access it like this: index.php?name=whatever then $name will be whatever, and anyone could access the page that way. The easiest workaround is to turn off register_globals and access superglobals with $_POST, $_SESSION, etc.

HTH,

Snib

<><
 
Old May 15th, 2004, 10:15 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Hi Hostile,
As you can imagine this topic has come up quite a bit, rather than beat a dead horse reiterating all the information conveyed countless times in previous posts, have a read of Nik's register_globals FAQ, then try a google search.

http://p2p.wrox.com/archive/beginnin...2002-11/17.asp
http://www.google.com/search?q=regis...e:p2p.wrox.com

After exploring the archives a bit, if you still have questions about it, let us know.


Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old May 15th, 2004, 11:09 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help guys. I'll take a look at those links Richard.

Cheers

Iain





Similar Threads
Thread Thread Starter Forum Replies Last Post
Text To HTML sumith ASP.NET 2.0 Basics 1 October 25th, 2007 02:26 AM
how to extract text from html??? naureen Java Basics 2 October 2nd, 2007 11:19 AM
HTML text interpretation omsadgamaya Crystal Reports 2 September 15th, 2006 07:23 AM
HTML text search JAtkinson VS.NET 2002/2003 0 February 29th, 2004 10:17 PM
Formatted/HTML text pkgal79 HTML Code Clinic 2 June 18th, 2003 02:18 AM





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