TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-22-2008, 11:34 AM   #1 (permalink)
The Visitor
 
Join Date: May 2008
Posts: 2
Thanks: 1
bedri is on a distinguished road
Default A serious curl checkbox problem

Hi,

I have a serious problem that i couldnt managed to solve.
I'm writin a PHP program that manages an optical switch. I'm gettin the data from the switch with curl and modifying some switch settings with curl post. In the curl post section everything is good except the checkbox thing. As far as i understand the switch wants some 1-0 value for the checkbox but it may be different as well since for some other variables, it sometimes accepts some other string values so i cannot be sure. I can set the value to the switch if the checkbox is checked but for an unchecked post it does not set the checked value as unchecked. I just look for the
PHP Code:
print_r($_REQUEST); 
. With an checked box it sends "on" value but with an unchecked box it sends a NULL value so the variable couldnt set in the $_REQUEST array. I had sent a NULL value to the switch as well but it didn't worked. I sent 0 or "off" values as well. Neither didn't worked.

Can you help me in this problem please?
bedri is offline  
Reply With Quote
Old 05-22-2008, 04:25 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You can always check if the GET/POST item is set or not. If it is set then it's been checked, otherwise it's not been checked. An alternative would be to supply a hidden attribute before the check box. That way if the check box is not checked, the value will be taken from the hidden element, otherwise if it is checked, the priority ordering will consider the second element with the same name to be the correct one.

Something like the following:

html4strict Code:
<form method="get">

    <input type="hidden" name="TalkPHPCheckbox" value="0" />
    <input type="checkbox" name="TalkPHPCheckbox" value="1" />
   
    <input type="submit" />

</form>

And of course the PHP to go along with it:

php Code:
if(isset($_GET['TalkPHPCheckbox']))
{
    echo $_GET['TalkPHPCheckbox'] == 0 ? 'Off' : 'On';
}
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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


All times are GMT. The time now is 06:09 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design