Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 13th, 2004, 10:30 AM
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form problem

Hi Guys,

In a Form I'm using the following field;

<input type="Text" name="quant<? echo $intID; ?>" maxlength="2" size="2" value="<? echo $intQuant; ?>">

it is used in a shopping cart, so more than one of these can exist in the form.
in ASP i've previously used 'request.form("quant"&intID&"")' to retreive the form value. however, in PHP i haven't had any success yet.

Could someone help me out?

Thanks

HammR

Reply With Quote
  #2 (permalink)  
Old March 13th, 2004, 11:46 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Ah... you need $_GET and $_POST

page1.php

<form method=post action=page2.php>
<input type="Text" name="quant<?php echo $intID; ?>" maxlength="2" size="2" value="<?php echo $intQuant; ?>">
</form>

page2.php

<?php
if(isset($_POST['quant' . $intID])) $textbox = $_POST['quant' . $intID];
?>

This example uses $_POST

When the form method is GET then use $_GET

http://www.php.net/variables.predefined

HTH,

----------
---Snib---
----------
Reply With Quote
  #3 (permalink)  
Old March 17th, 2004, 01:27 PM
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Snib,

However, the code you provided is working when using PHP version 4.3.4 (on a Windows machine), but does not work on PHP 4.0.6 (on a linuxserver).
any solution for this? besides upgrading..;)

Thanks!

Reply With Quote
  #4 (permalink)  
Old March 17th, 2004, 02:05 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hmm... try replacing $_GET and $_POST with $HTTP_GET_VARS and $HTTP_POST_VARS

Not sure this will work, but its worth a try!:)

----------
---Snib---
----------

<><
Reply With Quote
  #5 (permalink)  
Old March 17th, 2004, 09:14 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It will work as long as you guarantee that HTTP_xxx_VARS is in scope. These variables are *NOT* superglobal arrays; that is, they need to be explicitly imported into function scope if you're using them within a function.

You can do this via the global keyword:

function foo()
{
    global $HTTP_POST_VARS;

    echo $HTTP_POST_VARS['quant'];
}


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Problem prasanta2expert C# 1 September 24th, 2007 08:57 PM
Upload.Form problem barkerl Classic ASP Basics 1 January 22nd, 2007 06:06 AM
Sum on a form Problem Corey Access 1 November 9th, 2005 05:43 PM
form problem nulogix PHP How-To 4 June 16th, 2004 12:08 PM
Form problem tonyh Beginning VB 6 4 October 28th, 2003 03:11 PM



All times are GMT -4. The time now is 10:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.