php-general Digest 17 Apr 2009 11:47:52 -0000 Issue 6072

Topics (messages 291593 through 291612):

Re: Need Your Help :) I'm Just About Creating File Uploading Service
        291593 by: Michael A. Peters
        291594 by: Nitsan Bin-Nun
        291595 by: Michael A. Peters

cURL Download
        291596 by: Robbert van Andel

array manipulation
        291597 by: PJ
        291599 by: PJ
        291602 by: German Geek

Re: redirect to a page the fist time a site is accessed
        291598 by: Clancy

catching up
        291600 by: Tim | iHostNZ
        291601 by: German Geek

pup
        291603 by: ramesh.marimuthu.wipro.com
        291604 by: German Geek
        291605 by: ramesh.marimuthu.wipro.com
        291607 by: Jim Lucas
        291608 by: ramesh.marimuthu.wipro.com
        291609 by: Jim Lucas
        291610 by: Jim Lucas
        291611 by: ramesh.marimuthu.wipro.com
        291612 by: Alpár Török

Re: cURL - Error 400
        291606 by: David

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Michael A. Peters wrote:
Nitsan Bin-Nun wrote:
Neh, we don't have plenty of these in Israel, don't count it in as an issue.

Serving the files won't be an overkill for my harddrive / cpu usage /
anything else?

There is a better way to serve the files with/without PHP and keeping them
outsite of the HTTP root?

If you want to use http the code I provided in my first response works very well for files I serve outside the web root.

make a dummy directory in the web root.
In that dummy directory put a single php file - called "dummy.php" or whatever.

Have that file check the users credentials etc. (IE via session id) - and have

$thispage=$_SERVER['REQUEST_URI'];

put a .htaccess file in the dummy directory containing:

RewriteEngine on
RewriteRule ^*\.iso$ dummy.php

That assumes apache is your server, you have the mod_rewrite module, and allow .htaccess override (if you don't want to allow .htaccess overide you can put the rewrite directive right in the http.conf for the dummy directory)
--- End Message ---
--- Begin Message ---
It's really simple and I wrote several of these long time before, but I
thought that there might be an option of serving the files w/o using PHP to
read it and send the headers and chunks using only htaccess for the serving
and PHP for the validation of the session.

On Thu, Apr 16, 2009 at 10:58 PM, Michael A. Peters <[email protected]> wrote:

> Nitsan Bin-Nun wrote:
>
>> Neh, we don't have plenty of these in Israel, don't count it in as an
>> issue.
>>
>> Serving the files won't be an overkill for my harddrive / cpu usage /
>> anything else?
>>
>> There is a better way to serve the files with/without PHP and keeping them
>> outsite of the HTTP root?
>>
>
> If you want to use http the code I provided in my first response works very
> well for files I serve outside the web root.
>
> make a dummy directory in the web root.
> In that dummy directory put a single php file - called "dummy.php" or
> whatever.
>
> Have that file check the users credentials etc. (IE via session id) - and
> have
>
> $thispage=$_SERVER['REQUEST_URI'];
>
> put a .htaccess file in the dummy directory containing:
>
> RewriteEngine on
> RewriteRule ^*\.iso$ dummy.php
>
> That way a request to /dummy/something.iso
>
> is handled by dummy.php - which then can figure out what file is wanted via
> the $thispage variable, verify the user has permission to download it via
> sessions etc. (and sends a 403 header if they don't), verifies that the file
> exists (and sends a 404 header if it doesn't), and then uses the code I
> outlined in my first post to grab the file from the real location that is
> outside the web root and sends it to the requesting client.
>
> It works quite well for me.
>

--- End Message ---
--- Begin Message ---
Nitsan Bin-Nun wrote:
It's really simple and I wrote several of these long time before, but I
thought that there might be an option of serving the files w/o using PHP to
read it and send the headers and chunks using only htaccess for the serving
and PHP for the validation of the session.

There might be - I'm not familiar with such a technique though.
You may be able to use php sessions to enter an IP into a database (or flat file) that standard apache access restrictions could use to determine whether or not to send the file.

IE upon succesful login from 192.168.15.7 - that IP is added to a list used in an apache "allow from" directive.

The potential problem I see with that is the IP address you associate with a session may be a proxy.

But there may be solutions to that.

--- End Message ---
--- Begin Message ---
I've been struggling to download a file from a network file share using
cURL, or whatever else will work.   All I want to do is get the contents of
a text file.  But when I run the code below I get this error "Error: 37 -
Couldn't open file \\server\share\test.txt".  I'm running my website on a
linux box, but the server is on a Windows file server.  I've verified that
the file share works when I use Windows Explorer and that the server can get
the file via the command line using smbclient.  Any help would be
appreciated.

<?PHP
$file = "file:\\\\server\\share\\test.txt";

    echo "<p>Getting $file</p>\n";

    // create a new cURL resource
    $ch = curl_init();

    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, $file);
    curl_setopt($ch, CURLOPT_USERPWD, "username:password");
    curl_setopt($ch, CURLOPT_HEADER, false);

    // grab file and pass it to the browser
    echo "<p>File: " . curl_exec($ch) ."</p>\n";
    echo "<p>Error: " . curl_errno($ch) . " - " . curl_error($ch) .
"</p>\n";
?>

Thanks,
Robbert

--- End Message ---
--- Begin Message ---
The more I get into arrays, the less I understand.
I have a ridiculously simple task which excapes me completely.
I need to ouput all fields in 1 column from 1 table in two phases sorted
alphabetically.
So, I have the query, I have the results. But since I need to split the
list into 2 parts, I need indexes. I cannot use the table index as it
does not correspond to the alphabetical order of the data column. In
order to get the index, I sort the resulting array and that now gives me
34 arrays each containing an array of my results. Wonderful!
But how do I now extract the arrays from the array?

Here is what I'm trying to do:

$SQL = "SELECT category
        FROM categories
        ORDER BY category ASC
        ";
$category = array();
if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
            while ( $row = mysql_fetch_assoc($results) ) {
                $category[$row['category']] = $row;
                }
            sort($category);
            //var_dump($category);
            echo "<table >";
            $count = mysql_num_rows($results);
            $lastIndex = $count/2 -1; echo $lastIndex;
            $ii = 0;
            $cat = '';
//print_r($category['0']['category']);
    foreach($category as $index => $value) {
        $ii++;
        if ($ii != $lastIndex) {
            $cat .= "$value, ";
            }
        else {
            $cat .= " & $value<br />";
            }
        $catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat);
        //echo "<pre>$category</pre>";
        echo "<tr>
                <td><a href='../categories/", $catn, ".php'>", $cat, "</a>
                </td>
            </tr>" ;
        }
}
echo "</table>";

What should I be using in the foreach line?
Please help!

-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
Sorry, bout that.
My brain wasn't working right.
It was a lot simpler than I thought. Forget the foreach.
I used a counter. :-[

PJ wrote:
> The more I get into arrays, the less I understand.
> I have a ridiculously simple task which excapes me completely.
> I need to ouput all fields in 1 column from 1 table in two phases sorted
> alphabetically.
> So, I have the query, I have the results. But since I need to split the
> list into 2 parts, I need indexes. I cannot use the table index as it
> does not correspond to the alphabetical order of the data column. In
> order to get the index, I sort the resulting array and that now gives me
> 34 arrays each containing an array of my results. Wonderful!
> But how do I now extract the arrays from the array?
>
> Here is what I'm trying to do:
>
> $SQL = "SELECT category
>         FROM categories
>         ORDER BY category ASC
>         ";
> $category = array();
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
>             while ( $row = mysql_fetch_assoc($results) ) {
>                 $category[$row['category']] = $row;
>                 }
>             sort($category);
>             //var_dump($category);
>             echo "<table >";
>             $count = mysql_num_rows($results);
>             $lastIndex = $count/2 -1; echo $lastIndex;
>             $ii = 0;
>             $cat = '';
> //print_r($category['0']['category']);
>     foreach($category as $index => $value) {
>         $ii++;
>         if ($ii != $lastIndex) {
>             $cat .= "$value, ";
>             }
>         else {
>             $cat .= " & $value<br />";
>             }
>         $catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat);
>         //echo "<pre>$category</pre>";
>         echo "<tr>
>                 <td><a href='../categories/", $catn, ".php'>", $cat, "</a>
>                 </td>
>             </tr>" ;
>         }
> }
> echo "</table>";
>
> What should I be using in the foreach line?
> Please help!
>
>   


-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
soln: YOU NEED A 2 WEEK HOLLIDAY at least! You need to learn to say no.
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn<http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html>
- "A wide screen just makes a bad film twice as bad."

2009/4/17 PJ <[email protected]>

> The more I get into arrays, the less I understand.
> I have a ridiculously simple task which excapes me completely.
> I need to ouput all fields in 1 column from 1 table in two phases sorted
> alphabetically.
> So, I have the query, I have the results. But since I need to split the
> list into 2 parts, I need indexes. I cannot use the table index as it
> does not correspond to the alphabetical order of the data column. In
> order to get the index, I sort the resulting array and that now gives me
> 34 arrays each containing an array of my results. Wonderful!
> But how do I now extract the arrays from the array?
>
> Here is what I'm trying to do:
>
> $SQL = "SELECT category
>        FROM categories
>        ORDER BY category ASC
>        ";
> $category = array();
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
>            while ( $row = mysql_fetch_assoc($results) ) {
>                $category[$row['category']] = $row;
>                }
>            sort($category);
>            //var_dump($category);
>            echo "<table >";
>            $count = mysql_num_rows($results);
>            $lastIndex = $count/2 -1; echo $lastIndex;
>            $ii = 0;
>            $cat = '';
> //print_r($category['0']['category']);
>    foreach($category as $index => $value) {
>        $ii++;
>        if ($ii != $lastIndex) {
>            $cat .= "$value, ";
>            }
>        else {
>            $cat .= " & $value<br />";
>            }
>        $catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat);
>        //echo "<pre>$category</pre>";
>        echo "<tr>
>                <td><a href='../categories/", $catn, ".php'>", $cat, "</a>
>                </td>
>            </tr>" ;
>        }
> }
> echo "</table>";
>
> What should I be using in the foreach line?
> Please help!
>
> --
> unheralded genius: "A clean desk is the sign of a dull mind. "
> -------------------------------------------------------------
> Phil Jourdan --- [email protected]
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Thu, 16 Apr 2009 09:26:52 -0500, [email protected] (Shawn McKenzie) wrote:

>Stuart wrote:
>> 2009/4/15 Don <[email protected]>:
>>> I have some code in my index.php file that check the user agent and
>>> redirects to a warning page if IE 6 or less is encountered.
>>>
>>> 1. I'm using a framework and so calls to all pages go through index.php
>>> 2. The code that checks for IE 6 or less and redirects is in index.php
>>>
>>> I know how to redirect the users but what I want to do is redirect a user
>>> ONLY the first time the web site is accessed regardless of what page they
>>> first access.  I would like to minimize overhead (no database).  Can this be
>>> done?
>> 
>> Why redirect? That sucks as a user experience. Why not simply put an
>> alert somewhere prominent on the page with the message you want to
>> convey? That way you can have it on every page and not interrupt the
>> users use of your site.
>
>I agree, and you can still try the cookie method to not show the
>message, but it's not a big deal if they don't get the cookie/it expires
>etc., because the worst thing that can happen is that they see the message.

Alternatively add a link 'If you are new/Introduction/etc' that the new user 
can click to
get more information if they want it.


--- End Message ---
--- Begin Message ---
Hey guys,

Just trying to catch up to the rest of the world again. Prob wont be able to
read all the php mail.

Just one thing: Maybe PHP should be renamed to PFP (PHP Free Processor) or
something. A recursive acronym sort of suggests that you cannot be free or
break out of this infinite loop. What do you think? It could introduce
another variable call it $f (for FREE of course, nothing else you dirty
minded people), you get the idea.

Btw donations on my website are not abused, but rediculously low. I was
planning to make my CSV to SQL program free software, but without donations
im afraid ill have to fight a court case with the guy who owns me.

i love diet coke or coke zero is even better. advertisement not intended.

Cheers,
Tim
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn<http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html>
- "A wide screen just makes a bad film twice as bad."

--- End Message ---
--- Begin Message ---
just in case/tim(e). Yes its me :)
Tim-Hinnerk Heuer

http://www.ihostnz.com
Mitch Hedberg<http://www.brainyquote.com/quotes/authors/m/mitch_hedberg.html>
- "I drank some boiling water because I wanted to whistle."

---------- Forwarded message ----------
From: Tim | iHostNZ <[email protected]>
Date: 2009/4/17
Subject: catching up
To: PHP General list <[email protected]>


Hey guys,

Just trying to catch up to the rest of the world again. Prob wont be able to
read all the php mail.

Just one thing: Maybe PHP should be renamed to PFP (PHP Free Processor) or
something. A recursive acronym sort of suggests that you cannot be free or
break out of this infinite loop. What do you think? It could introduce
another variable call it $f (for FREE of course, nothing else you dirty
minded people), you get the idea.

Btw donations on my website are not abused, but rediculously low. I was
planning to make my CSV to SQL program free software, but without donations
im afraid ill have to fight a court case with the guy who owns me.

i love diet coke or coke zero is even better. advertisement not intended.

Cheers,
Tim
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn<http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html>
- "A wide screen just makes a bad film twice as bad."

--- End Message ---
--- Begin Message ---
Hi,

I'm new to this list. Can I post PUP questions to this list?

regards,
-ramesh

P Save a tree...please don't print this e-mail unless you really need to


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

--- End Message ---
--- Begin Message ---
>From What i learned, yes you can write pup here. Does anyone print this
mailing list? wtf?? i keep overestimating people's intelligence, im sorry!
Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles de 
Gaulle<http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html>
- "The better I get to know men, the more I find myself loving dogs."

2009/4/17 <[email protected]>

> Hi,
>
> I'm new to this list. Can I post PUP questions to this list?
>
> regards,
> -ramesh
>
> P Save a tree...please don't print this e-mail unless you really need to
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to
> this message are intended for the exclusive use of the addressee(s) and may
> contain proprietary, confidential or privileged information. If you are not
> the intended recipient, you should not disseminate, distribute or copy this
> e-mail. Please notify the sender immediately and destroy all copies of this
> message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses. The
> company accepts no liability for any damage caused by any virus transmitted
> by this email.
>
> www.wipro.com
>

--- End Message ---
--- Begin Message ---
Hi,

I'm new to php.
Say I have a check box which is checked already. Now I need to uncheck
it and when I press the submit button, I should get the unchecked value.
Can anyone help me on this.

One.php

if($qry[0]!=$login_type)
{
echo "<td class=tabhead align=center
style=background-color:#CC66CC><input type=checkbox name=disable
value=a".$count." checked DISABLED /></br>".$slot_value."</td>";
}
else
{
echo "<td class=tabhead align=center
style=background-color:#00CCCC><input type=checkbox name=enable[]
value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."' checked
></br>".$slot_value."</td>";
}

One.php calls Two.php
Two.php

$enable_slot= $_POST['enable'];
$uncheck_slot= $_POST['uncheck'];

if ($enable_slot){
echo "$enable_slot";
foreach($enable_slot as &$a) {
echo "<p>".$a." --unreserve</p>";
}
}

I get only the results only if checked. I think I'm doing a mistake in
the code in red font.

regards,
-rummy


________________________________

From: [email protected] [mailto:[email protected]] On Behalf Of German
Geek
Sent: Friday, April 17, 2009 9:47 AM
To: Ramesh Marimuthu (WT01 - Telecom Equipment)
Cc: [email protected]
Subject: Re: [PHP] pup


>From What i learned, yes you can write pup here. Does anyone print this
mailing list? wtf?? i keep overestimating people's intelligence, im
sorry!
Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles de Gaulle
<http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html>   -
"The better I get to know men, the more I find myself loving dogs."


2009/4/17 <[email protected]>


        Hi,

        I'm new to this list. Can I post PUP questions to this list?

        regards,
        -ramesh

        P Save a tree...please don't print this e-mail unless you really
need to


        Please do not print this email unless it is absolutely
necessary.

        The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
addressee(s) and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately and destroy all copies of this message and any attachments.

        WARNING: Computer viruses can be transmitted via email. The
recipient should check this email and any attachments for the presence
of viruses. The company accepts no liability for any damage caused by
any virus transmitted by this email.

        www.wipro.com




Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

--- End Message ---
--- Begin Message ---
[email protected] wrote:
Hi, I'm new to php.
Say I have a check box which is checked already. Now I need to uncheck
it and when I press the submit button, I should get the unchecked value.
Can anyone help me on this.

One.php

if($qry[0]!=$login_type)
{
echo "<td class=tabhead align=center
style=background-color:#CC66CC><input type=checkbox name=disable
value=a".$count." checked DISABLED /></br>".$slot_value."</td>";
}
else
{
echo "<td class=tabhead align=center
style=background-color:#00CCCC><input type=checkbox name=enable[]
value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."' checked
</br>".$slot_value."</td>";
}

One.php calls Two.php
Two.php

$enable_slot= $_POST['enable'];
$uncheck_slot= $_POST['uncheck'];

if ($enable_slot){
echo "$enable_slot";
foreach($enable_slot as &$a) {
echo "<p>".$a." --unreserve</p>";
}
}

I get only the results only if checked. I think I'm doing a mistake in
the code in red font.

regards,
-rummy


When you uncheck a checkbox in an HTML form, it will not be submitted.

http://www.w3.org/TR/html401/interact/forms.html#checkbox

The part on the above page talking about "only "on" checkbox controls can become 
successful." is the key here.

The successful part links here:

http://www.w3.org/TR/html401/interact/forms.html#successful-controls

This explains that the definition of a successful checkbox submission is one that is  
"on".
To have a checkbox in the "on" state means that it has to be checked.

So, any checkbox that is /not/ checked is considered "off" or "undefined" will 
not be submitted because it is not valid.

Or something like that... :)

Jim Lucas

--- End Message ---
--- Begin Message ---
Thanks Jim. Is there a way to get the value of that unchecked box?

-rummy

-----Original Message-----
From: Jim Lucas [mailto:[email protected]]
Sent: Friday, April 17, 2009 10:35 AM
To: Ramesh Marimuthu (WT01 - Telecom Equipment)
Cc: [email protected]; [email protected]
Subject: Re: [PHP] pup

[email protected] wrote:
>
> Hi,
>
> I'm new to php.
> Say I have a check box which is checked already. Now I need to uncheck

> it and when I press the submit button, I should get the unchecked
value.
> Can anyone help me on this.
>
> One.php
>
> if($qry[0]!=$login_type)
> {
> echo "<td class=tabhead align=center
> style=background-color:#CC66CC><input type=checkbox name=disable
> value=a".$count." checked DISABLED /></br>".$slot_value."</td>"; }
> else { echo "<td class=tabhead align=center
> style=background-color:#00CCCC><input type=checkbox name=enable[]
> value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."'
> checked
>> </br>".$slot_value."</td>";
> }
>
> One.php calls Two.php
> Two.php
>
> $enable_slot= $_POST['enable'];
> $uncheck_slot= $_POST['uncheck'];
>
> if ($enable_slot){
> echo "$enable_slot";
> foreach($enable_slot as &$a) {
> echo "<p>".$a." --unreserve</p>";
> }
> }
>
> I get only the results only if checked. I think I'm doing a mistake in

> the code in red font.
>
> regards,
> -rummy
>
>

When you uncheck a checkbox in an HTML form, it will not be submitted.

http://www.w3.org/TR/html401/interact/forms.html#checkbox

The part on the above page talking about "only "on" checkbox controls
can become successful." is the key here.

The successful part links here:

http://www.w3.org/TR/html401/interact/forms.html#successful-controls

This explains that the definition of a successful checkbox submission is
one that is  "on".
To have a checkbox in the "on" state means that it has to be checked.

So, any checkbox that is /not/ checked is considered "off" or
"undefined" will not be submitted because it is not valid.

Or something like that... :)

Jim Lucas

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

--- End Message ---
--- Begin Message ---
[email protected] wrote:
Thanks Jim. Is there a way to get the value of that unchecked box?
-rummy

-----Original Message-----
From: Jim Lucas [mailto:[email protected]] Sent: Friday, April 17, 2009 10:35 AM
To: Ramesh Marimuthu (WT01 - Telecom Equipment)
Cc: [email protected]; [email protected]
Subject: Re: [PHP] pup

[email protected] wrote:
Hi, I'm new to php.
Say I have a check box which is checked already. Now I need to uncheck

it and when I press the submit button, I should get the unchecked
value.
Can anyone help me on this.

One.php

if($qry[0]!=$login_type)
{
echo "<td class=tabhead align=center
style=background-color:#CC66CC><input type=checkbox name=disable value=a".$count." checked DISABLED /></br>".$slot_value."</td>"; } else { echo "<td class=tabhead align=center style=background-color:#00CCCC><input type=checkbox name=enable[] value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."' checked
</br>".$slot_value."</td>";
}

One.php calls Two.php
Two.php

$enable_slot= $_POST['enable'];
$uncheck_slot= $_POST['uncheck'];

if ($enable_slot){
echo "$enable_slot";
foreach($enable_slot as &$a) {
echo "<p>".$a." --unreserve</p>";
}
}

I get only the results only if checked. I think I'm doing a mistake in

the code in red font.

regards,
-rummy


When you uncheck a checkbox in an HTML form, it will not be submitted.

http://www.w3.org/TR/html401/interact/forms.html#checkbox

The part on the above page talking about "only "on" checkbox controls
can become successful." is the key here.

The successful part links here:

http://www.w3.org/TR/html401/interact/forms.html#successful-controls

This explains that the definition of a successful checkbox submission is
one that is  "on".
To have a checkbox in the "on" state means that it has to be checked.

So, any checkbox that is /not/ checked is considered "off" or
"undefined" will not be submitted because it is not valid.

Or something like that... :)

Jim Lucas

Please do not print this email unless it is absolutely necessary. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com


Maybe create a hidden input tag right next to it that references some default 
value.

Why are you wanting to get a value if it is not checked?

If this is what you are looking for are you sure that a checkbox is the right 
form input type to be using?

Jim Lucas

--- End Message ---
--- Begin Message ---
[email protected] wrote:
I'm developing a slot reservation page. It shows checked boxes for the
currently logged user. If he likes to unreserve it, he should uncheck
it. For other users it is disabled. Also a currently logged user can
book another slot.

Also when I use hidden types, only if all the checked boxes are
unchecked, I could get the hidden values.

-rummy


You could use an array system in your checkbox form section.?

Basically, take your check boxes.  I am assuming that you have a defined list 
of what is expected?  Correct?

Have your elements setup like such:



<input type="checkbox" name="reserve[rm1]" value="yes" /> Room #1
<input type="checkbox" name="reserve[rm2]" value="yes" /> Room #2
<input type="checkbox" name="reserve[rm3]" value="yes" /> Room #3
<input type="checkbox" name="reserve[rm4]" value="yes" /> Room #4
<input type="checkbox" name="reserve[rm5]" value="yes" /> Room #5


Then on your processing page, you know that you have 5 rooms, 1 - 5.

With this information you can check to make sure that something exists

<?php

$rooms = range(1,5);

for ( $i = 1; $i <= 5; $i++ ) {
        if ( isset( $_POST['reserve']['rm'.$i] ) {
                # Room was checked
        } else {
                # Room was NOT checked.
        }
}

?>

Something like that should do the trick.

Jim Lucas

--- End Message ---
--- Begin Message ---
Many Thanks Jim. Your idea worked.

-rummy

-----Original Message-----
From: Jim Lucas [mailto:[email protected]]
Sent: Friday, April 17, 2009 11:13 AM
To: Ramesh Marimuthu (WT01 - Telecom Equipment); PHP General List;
[email protected]
Subject: Re: [PHP] pup

[email protected] wrote:
> I'm developing a slot reservation page. It shows checked boxes for the

> currently logged user. If he likes to unreserve it, he should uncheck
> it. For other users it is disabled. Also a currently logged user can
> book another slot.
>
> Also when I use hidden types, only if all the checked boxes are
> unchecked, I could get the hidden values.
>
> -rummy
>

You could use an array system in your checkbox form section.?

Basically, take your check boxes.  I am assuming that you have a defined
list of what is expected?  Correct?

Have your elements setup like such:



<input type="checkbox" name="reserve[rm1]" value="yes" /> Room #1 <input
type="checkbox" name="reserve[rm2]" value="yes" /> Room #2 <input
type="checkbox" name="reserve[rm3]" value="yes" /> Room #3 <input
type="checkbox" name="reserve[rm4]" value="yes" /> Room #4 <input
type="checkbox" name="reserve[rm5]" value="yes" /> Room #5


Then on your processing page, you know that you have 5 rooms, 1 - 5.

With this information you can check to make sure that something exists

<?php

$rooms = range(1,5);

for ( $i = 1; $i <= 5; $i++ ) {
        if ( isset( $_POST['reserve']['rm'.$i] ) {
                # Room was checked
        } else {
                # Room was NOT checked.
        }
}

?>

Something like that should do the trick.

Jim Lucas

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

--- End Message ---
--- Begin Message ---
2009/4/17 German Geek <[email protected]>:
> From What i learned, yes you can write pup here. Does anyone print this
> mailing list? wtf?? i keep overestimating people's intelligence, im sorry!
> Tim-Hinnerk Heuer

It would be interested to see how  many times the Earth can be covered
or surrounded, with the printed version of this mailing list.

>
> http://www.ihostnz.com
> Charles de 
> Gaulle<http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html>
> - "The better I get to know men, the more I find myself loving dogs."
>
> 2009/4/17 <[email protected]>
>
>> Hi,
>>
>> I'm new to this list. Can I post PUP questions to this list?
>>
>> regards,
>> -ramesh
>>
>> P Save a tree...please don't print this e-mail unless you really need to
>>
>>
>> Please do not print this email unless it is absolutely necessary.
>>
>> The information contained in this electronic message and any attachments to
>> this message are intended for the exclusive use of the addressee(s) and may
>> contain proprietary, confidential or privileged information. If you are not
>> the intended recipient, you should not disseminate, distribute or copy this
>> e-mail. Please notify the sender immediately and destroy all copies of this
>> message and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The recipient
>> should check this email and any attachments for the presence of viruses. The
>> company accepts no liability for any damage caused by any virus transmitted
>> by this email.
>>
>> www.wipro.com
>>
>



-- 
Alpar Torok

--- End Message ---
--- Begin Message ---
Hi,

Sorry, that didn't work. The website is still returning error 400 with
CURLOPT_COOKIESESSION and CURLOPT_COOKIE enabled.

I did some experimentation in Firefox by blocking and deleting all cookies
from the site. When I then visited the site, I was able to reach the logon
page without returning error 400 so I doubt it's cookies that is the
problem.

I also tried changing the HTTP headers to:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

Which didn't work either.




Thanks

On Thu, Apr 16, 2009 at 11:48 PM, haliphax <[email protected]> wrote:

> On Wed, Apr 15, 2009 at 9:17 PM, David <[email protected]> wrote:
> > Except I also need to POST data to the server to login. After I've logged
> > in, I then need to use cookies to maintain a session.
> >
> > Doing that via file_get_contents() just isn't possible.
> >
> >
> > Thanks
> >
> > On Thu, Apr 16, 2009 at 2:30 AM, haliphax <[email protected]> wrote:
> >>
> >> On Wed, Apr 15, 2009 at 10:36 AM, David <[email protected]>
> wrote:
> >> > I was wondering if anyone could please help me with this cURL script
> >> > since I
> >> > keep getting error 400 from the web server:
> >> >
> >> > http://pastebin.ca/1392840
> >> >
> >> > It worked until around a month ago which is when they presumably made
> >> > changes to the site. Except I can't figure out what configuration
> option
> >> > in
> >> > the cURL PHP script needs to be changed. I can visit the site
> perfectly
> >> > in
> >> > Lynx, Firefox and IE.
> >>
> >> Are you just trying to get the contents of the page, or is there
> >> something special you're doing? If it's just the contents you're
> >> after, try file_get_contents() if allow_url_fopen is set to TRUE for
> >> your PHP installation.
> >>
> >> http://php.net/file_get_contents
> >> http://php.net/allow_url_fopen
>
> David, please refrain from top-posting.
>
> As for cURL login/session handling... I have an automated script that
> connects to a phpBB bulletin board, and here are the settings that
> have worked for me:
>
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($ch, CURLOPT_COOKIESESSION, true);
> curl_setopt($ch, CURLOPT_HEADER, false);
> curl_setopt($ch, CURLOPT_COOKIEFILE, "{$homedir}cookiefile");
> curl_setopt($ch, CURLOPT_COOKIEJAR, "{$homedir}cookiefile");
> curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
>
> I would think CURLOPT_FOLLOWLOCATION and the CURLOPT_COOKIE* options
> are most important for resolving your issue.
>
> HTH,
>
>
> --
> // Todd
>

--- End Message ---

Reply via email to