Old 07-07-2005   #1 (permalink)
Registered User
 
Join Date: Jul 2005
Posts: 3

Im trying to make a PHP cart

Hello,

I am new to PHP, its only been a few days. So I figure what better to learn then to make my own script. Anyway I am stuck on something that seems should be simple....

On my product page there is a 'drop select' and a submit button.

This code is:

<form method='post' action='cart.php'>
<input type='hidden' name='code' value='0222'>
<select name='num' size='1'>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type='submit'></form>

My question is.... How do you umm, get the value from 'drop select'... "num" ?

$_POST[code] works

but

$_POST[num] doesn't.
cnotation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-07-2005   #2 (permalink)
Invicible Snake
 
ParaSnake's Avatar
 
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668

Send a message via MSN to ParaSnake Send a message via Yahoo to ParaSnake
I dont know what has happened to you,but heres its work

PHP Code:

if(!$_POST['submit']) {
    echo 
"<form method='post' action=''>
    <input type='hidden' name='code' value='0222'>
    <select name='num' size='1'>
    <option value=1>1</option>
    <option value=2>2</option>
    <option value=2>3</option>
    </select>
    <input type='submit' name='submit'></form>"
;
}
else {
    echo 
$_POST['code'];
    echo 
"<BR>";
    echo 
$_POST['num'];


May be you was wrong with $_POST[num],it should be $_POST['num']
__________________
ParaSnake is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-07-2005   #3 (permalink)
Registered User
 
Join Date: Jul 2005
Posts: 3

Thanks, I tried $_POST['num'].. didnt work either.. is there another way to get the value??
cnotation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-07-2005   #4 (permalink)
Local Biorust Beast
 
Order's Avatar
 
Join Date: Oct 2003
Location: San Diego, CA, USA
Posts: 2,253

Send a message via AIM to Order Send a message via MSN to Order Send a message via Yahoo to Order
sounds like you are losing that return value somewhere. try this on cart.php:

PHP Code:
print_r($_POST); 
That should print out the values of your request, num should be in there, if not, post the output from the print_r.
__________________
Order is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-08-2005   #5 (permalink)
Registered User
 
Join Date: Jul 2005
Posts: 3

Quote:
Originally Posted by Order
sounds like you are losing that return value somewhere. try this on cart.php:

PHP Code:
print_r($_POST); 
That should print out the values of your request, num should be in there, if not, post the output from the print_r.
print_r($_POST);

gave me this..

Array ( [code] => 0222 [num] => )

Gosh this is annoying.. I cant even get past the second page. And the make matters worse... $_POST has failed me, what little confidence I had is shook.

I dont know why this works

foreach ($_POST as $field => $value)
{
echo "$field = $value<br>";
}
but the others dont
cnotation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-08-2005   #6 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
put quotes around your select box option values
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to make a website? Read this. Young Spartan HTML / PHP / ASP / JS 16 06-30-2006 02:12 AM
PHP Login Help Space Cowboy HTML / PHP / ASP / JS 11 06-01-2005 10:02 AM
Php... Joe HTML / PHP / ASP / JS 35 06-22-2004 12:08 AM
PHP Tutorial Requests Man1c M0g BioRUST Specific Threads 6 06-17-2004 09:16 PM
Digital's Quick and Dirty Guide to PHP Order HTML / PHP / ASP / JS 15 05-05-2004 01:18 AM


All times are GMT +1. The time now is 04:47 AM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT