LinuxQuestions.org
Review your favorite Linux distribution.
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 03-09-2009, 08:49 PM   #1
guest
Member
 
Registered: May 2003
Distribution: CentOS 5 64 bit
Posts: 255

Rep: Reputation: 30
what does the checkbox checked look like in a form post url?


i know strange question..

so i'm doing some cURL and have a checkbox name 'accept' i want to send as checked..

how does the 'accept' checkbox look like in the form post? is it accept=checked or accept=1?

the form:
Code:
 <form method="GET" action="post.php"> 
          <input type=text name="first_name"> 
          <input type=checkbox name="accept">
          <input type=submit name=press value="OK"> 
        </form>
the curl:
PHP Code:
<?
$url
='http://www.mysite.com/post.php';
$first_name='Jerry';
$postfields='first_name='.$first_name.'accept=1';
curl_setopt($chCURLOPT_URL$url); 
curl_setopt($chCURLOPT_HEADER1); 
curl_setopt($chCURLOPT_VERBOSEtrue); 
curl_setopt($chCURLOPT_USERAGENT$agent); 
curl_setopt($chCURLOPT_FOLLOWLOCATION1); 
curl_setopt($chCURLOPT_RETURNTRANSFER,1); 
curl_setopt($chCURLOPT_POST1); // 
curl_setopt($chCURLOPT_POSTFIELDS$postfields); 
$data=curl_exec($ch);
curl_close($ch); 
echo 
$data
?>
is the 'accept' supposed to =1 or =checked?

Last edited by guest; 03-10-2009 at 01:39 PM.
 
Old 03-10-2009, 12:45 PM   #2
guest
Member
 
Registered: May 2003
Distribution: CentOS 5 64 bit
Posts: 255

Original Poster
Rep: Reputation: 30
or maybe it's =on?

i tried all 3 and they all don't seem to work

Last edited by guest; 03-10-2009 at 01:40 PM.
 
Old 03-10-2009, 10:43 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
just:
Code:
<input type=checkbox name="accept" checked>
 
Old 04-20-2009, 05:18 PM   #4
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
Is the HTML page something you've written yourself? The checkbox should have a value attribute, e.g. something like:

Code:
<input type=checkbox name="accept" value="something">
In this case then you should sent accept=something

If you didn't write the HTML yourself then it will probably be enough to send the variable without a value, i.e.

PHP Code:
$postfields='first_name='.$first_name.'accept='
which may look odd, but the chances are in this case the server will simply check for the presence of the variable, and ignore its value.
 
  


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
JS IE: checkbox.checked doesn't work eantoranz Programming 8 07-27-2011 02:59 AM
VectorLinux user, must make post before I can post url The Headacher LinuxQuestions.org Member Intro 2 07-02-2011 11:55 AM
OpenOffice.org create form checkbox with no border Meson Linux - Software 0 09-03-2008 09:40 PM
question/ answer checkbox for each post schneidz LQ Suggestions & Feedback 1 02-19-2007 02:56 PM
firefox accept cookies checkbox cleared after being checked and FF restarted" skaramanger Mandriva 0 05-10-2006 06:20 PM

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

All times are GMT -5. The time now is 09:40 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