LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-10-2007, 03:18 PM   #1
woodpecka_04
Member
 
Registered: May 2007
Distribution: Fedora Core 6
Posts: 47

Rep: Reputation: 15
Obtaining check box value in PHP/HTML


Hello,

This seems like such a stupid question but I cannot find a solution anywhere. I have a form on a page to post a thread and a check box which is used to decide whether the poster remains anonymous or not. Sounds simple enough?

All I want to do is post the form and find out if the check box was checked or unchecked. I still can't find out how to do it!?

So say I have the input as:

<input type="checkbox" name="anonymous">

I just want to get the value contained in $_POST['anonymous']

I realise a check box returns an array, but I can't seem to access a value in anonymous[0].

Can someone please help me? It seems like such a trivial problem.

Thanks
 
Old 07-10-2007, 11:09 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
If I recall correctly the check box only returns a value if is it checked, so look to see if the value has been set
Code:
isset($_POST['anonymous'])
you can confirm this by printing out the value of $_POST.
 
Old 07-11-2007, 12:36 AM   #3
gamma9mu
LQ Newbie
 
Registered: Mar 2006
Location: LitH, IL
Distribution: Ubuntu Feisty
Posts: 6

Rep: Reputation: 0
[HTML]print "<pre>";
print_r ($_POST);
print "</pre>";[/HTML]

is always a good way of debugging post form output. you can use var_dump($_POST) in place of print_r($_POST), also. it gives slightly different info.
 
Old 07-11-2007, 01:52 PM   #4
woodpecka_04
Member
 
Registered: May 2007
Distribution: Fedora Core 6
Posts: 47

Original Poster
Rep: Reputation: 15
Thanks very much guys, worked a treat!

I thought it might be something simple like that in the end!

Cheers.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache rending php when filename is x.php.html mastahnke Linux - Server 6 01-22-2007 08:39 AM
check HTML colour using regular expression kaon Linux - General 1 07-27-2005 07:46 AM
html to php? help me please!!!!! trscookie Programming 4 01-24-2005 06:36 AM
Menu bar being blocked by combo box in html ArulPrabhuT Programming 3 01-05-2005 03:09 AM
how can I seprate normal text from html tags spell check it & then again place it ins amit_28oct Programming 5 08-07-2004 07:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration