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 July 25th, 2003, 03:13 AM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checkbox

When doing the exercise on p83 my results are not the same as in the book. On my php page I get this:

onChoice=on

My code is this:

<html>
<head></head>
<body>
<FORM METHOD=POST ACTION="checkbox.php">
Have you ever eaten haggis before?
<INPUT NAME="Choice" TYPE="CheckBox">
<br>
<br>
<INPUT TYPE=SUBMIT>
</FORM>
</body>
</html>

<html>
<head></head>
<body>
<?php
echo $Choice;
?>
</body>
</html>

Please can someone tell me why?


:(

 
Old July 27th, 2003, 04:29 PM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to fuddy
Default

to get variable to show (assuming global variables are turned off):

<html>
<head></head>
<body>
<?php
$Choice = $HTTP_POST_VARS['Choice'];
echo $Choice;
?>
</body>
</html>



jiggle before zip
 
Old August 15th, 2003, 03:30 PM
Registered User
 
Join Date: Aug 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or a wee bit shorter:

<html>
<head></head>
<body>
<?php
$Choice = $_POST['Choice'];
echo $Choice;
?>
</body>
</html>

Where's onChoice coming from??





 
Old August 19th, 2003, 10:43 PM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

From what I can gather onChoice means that the check box has a check in it so choice is on. But this was with Global Registers OFF. Once I switched to Gobal Registers ON I haven't had any more trouble. But I am wondering what to do in the future when I have to work with them OFF all the time?


 
Old August 20th, 2003, 01:58 PM
Authorized User
 
Join Date: Jul 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Chapter 8 talks about session variables. You'll be fine until then with these (depending on POST OR GET method):
$Choice = $_POST['Choice']; or
$Choice = $_GET['Choice'];

Oregon

 
Old August 20th, 2003, 10:52 PM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cool thanks will use this until I eventually reach Chpt 8! Fingers crossed!

 
Old August 30th, 2003, 08:34 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Its often helpful to know just WHY the PHP group changed the register_globals directive to off in the first place... this is explained in detail on the php.net website.

See Nik's register globals FAQ, Nik does a fine job of explaining the security issues with register_globals and why you should use the new superglobal arrays.
http://p2p.wrox.com/archive/beginnin...2002-11/17.asp

And as always, read the php manual:
http://www.php.net/manual/en/languag...predefined.php

It is going to be much easier for all you newbies out there to adapt to using php with the register_globals directive turned off, instead of taking the easy way out and just turning it back on in php.ini. For one the directive is deprecated, which if you aren't familar with the lingo means slated for deletion from the language all together. So in some future version of php this functionality won't even be available.

Just my two cents!

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
checkbox grstad HTML Code Clinic 1 December 18th, 2006 08:10 AM
checkbox checked by default by html:checkbox sachin.tathod Struts 3 December 4th, 2006 03:41 PM
Need Help regards checkbox nellaikumar ASP.NET 1.0 and 1.1 Basics 1 December 1st, 2005 02:07 PM
Checkbox johnjohn Classic ASP Basics 2 December 6th, 2004 06:03 PM
checkbox damnnono_86 Access 2 October 10th, 2003 03:25 AM





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