Re: [PHP] Header Keep-Alive

2013-05-27 Thread Sebastian Krebs
2013/5/27 Al 

> I'm trying to increase the connection timeout; but can't get it to work.
> Note: Keep-Alive gets repeated.
>
> I'm using:
> header("Connection: Keep-Alive");
> header("Keep-Alive: timeout=9, max=100");
>

Set the second optional argument to "true"
See http://de.php.net/manual/en/function.header.php


>
>
> I get:
> (Status-Line)   HTTP/1.1 200 OK
> DateMon, 27 May 2013 20:19:54 GMT
> Server  Apache
> Connection  Keep-Alive, Keep-Alive
> Keep-Alive  timeout=5, max=100
> Expires Thu, 19 Nov 1981 08:52:00 GMT
> Cache-Control   no-store, no-cache, must-revalidate, post-check=0,
> pre-check=0
> Pragma  no-cache
> Content-Encodinggzip
> VaryAccept-Encoding,User-Agent
> Set-Cookie  Coach::VermontCamp2013_**setupMode=**
> 58d7e534bec4ec57634c78caa59d8d**b2; expires=Sat, 23-Nov-2013 20:19:55
> GMT; path=/Coach/; domain=.ridersite.org
> Transfer-Encoding   chunked
> Content-Typetext/html; charset=utf-8
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
github.com/KingCrunch


[PHP] Header Keep-Alive

2013-05-27 Thread Al

I'm trying to increase the connection timeout; but can't get it to work. Note: 
Keep-Alive gets repeated.

I'm using:
header("Connection: Keep-Alive");
header("Keep-Alive: timeout=9, max=100");


I get:
(Status-Line)   HTTP/1.1 200 OK
DateMon, 27 May 2013 20:19:54 GMT
Server  Apache
Connection  Keep-Alive, Keep-Alive
Keep-Alive  timeout=5, max=100
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma  no-cache
Content-Encodinggzip
VaryAccept-Encoding,User-Agent
Set-Cookie	Coach::VermontCamp2013_setupMode=58d7e534bec4ec57634c78caa59d8db2; expires=Sat, 23-Nov-2013 20:19:55 GMT; 
path=/Coach/; domain=.ridersite.org

Transfer-Encoding   chunked
Content-Typetext/html; charset=utf-8

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] iterate javascript verification

2013-05-27 Thread Tim Dunphy
Sounds good! Thanks Ken. Very clear now.

Tim

Sent from my iPhone

On May 27, 2013, at 1:57 PM, Ken Robinson  wrote:

> When you do validation of the form in the same script that shows the form, 
> the normal way to do this is
> 
>if (isset($_POST['submit'])) {
> //
> //  validation here
> //
>}
> ?>
> 
> This won't work if you're getting to the page via another form, since the 
> $_POST['submit'] is set. There two ways of avoiding this:
> 
> 1) use hidden fields in each form to indicate which form was submitted
> 2) use a different name for each form's submit button and use that in the 
> above code
> 
> Ken
> 
> 
> At 12:52 PM 5/27/2013, Tim Dunphy wrote:
>> Hey guys,
>> 
>> Thanks for the input! This is pretty nice, and DOES work. I like the fact
>> that the fields have been into an iterative array. It's a very elegant
>> solution. However the problem with this approach is that if you load the
>> page directly it works. But if you call the page from the index.php page
>> you get an initial error on all fields as they are all quite naturally
>> empty when you first load the page.
>> 
>> Here's the index.php page. All it is is HTML, no php:
>> 
>> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
>> 
>>  
>>  LDAP Request Form
>> 
>> 
>>  LDAP Request Form
>>   > onsubmit="return validateForm()">
>>Your Email Address:
>>> />
>>How Many Forms Do You Need:
>>> name="num_forms" />
>>
>>  
>> 
>> 
>> 
>> And here is ldap.php as was suggested:
>> 
>> 
>> 
>>  > 
>>   if (isset($_POST['submit'])) {
>>$requestor_email = $_POST['requestor_email'];
>>$num_forms  = $_POST['num_forms'];
>>}
>> 
>> 
>>echo "You will be creating $num_forms accounts
>> today.";
>>for($counter = 1;$counter<=$num_forms;$counter++) {
>>echo '> action="sendemail.php" onsubmit="return validateForm()">';
>>echo '';
>>echo "Enter user: $counter";
>>echo "First Name:> />";
>>echo "> name=\"first_name_.$counter.\" />";
>>echo "Last Name:";
>>echo "> name=\"last_name_.$counter.\" />";
>>echo "Department:> />";
>>echo "> name=\"department_.$counter.\" />";
>>echo "Title:";
>>echo "> name=\"title_.$counter.\" />";
>>echo "Email:";
>>echo "> name=\"email_.$counter.\" />";
>>echo "Phone:";
>>echo "> name=\"phone_.$counter.\" />";
>>  }
>> 
>>  echo "> value=\"$num_forms\" />";
>>  echo "> name=\"requestor_email\" value=\"$requestor_email\" />";
>>  echo "";
>>  echo "";
>> 
>> 
>> 
>> 
>>   ?>
>> 
>> 
>> Why this happens when you call the ldap.php page from index.php but not
>> when you load the page directly beats me. But maybe someone can shed some
>> light on that?
>> 
>> Thanks!
>> 
>> 
>> 
>> On Sat, May 25, 2013 at 3:45 AM, tamouse mailing lists <
>> tamouse.li...@gmail.com> wrote:
>> 
>> > On Fri, May 24, 2013 at 9:51 PM, Ken Robinson  wrote:
>> > > I took your code and modified it to use HTML5 validation (and few other
>> > > changes). You can see the results at
>> > > 
>> > http://my-testbed.com/test1/form_validation.php
>> > >
>> > > My code follows:
>> > >
>> > >   > > >   $fields =
>> > > array('first_name','last_name','department','title','email','phone');
>> > >   $num_forms = 1;
>> > >   $tmp = array();
>> > >   $errors = array();
>> > >
>> > >
>> > >if (isset($_POST['submit'])) {
>> > > $requestor_email = $_POST['requestor_email'];
>> > > $num_forms  = $_POST['num_forms'];
>> > > for ($i = 1;$i <= $num_forms; ++$i) {
>> > > foreach ($fields as $fld) {
>> > > if ($_POST[$fld][$i] == '') {
>> > > $errors[] = ucwords(str_replace('_',' ',$fld)) .
>> > "
>> > > for account $i can not be blank";
>> > > }
>> > > }
>> > > }
>> > >   }
>> > > if (!empty($errors)) {
>> > > $tmp[] = "The following fields are in
>> > error:";
>> > > $tmp[] = implode("\n",$errors);
>> > > $tmp[] = "";
>> > > }
>> > > $tmp[] = "You will be creating
>> > $num_forms
>> > > accounts today.";
>> > > $tmp[] = '> > > method="post" action="">';
>> > > $tmp[] = '';
>> > >
>> > > for($counter = 1;$counter<=$num_forms;$counter++) {
>> > > $tmp[] = "Enter user: $counter";
>> > > $tmp[] = "First
>> > > Name:";
>> > > $tmp[] = "> > > name='first_name[$counter]'>";
>> > > $tmp[] = "Last Name:> > />";
>> > > $tmp[] = "> > > name='last_name[$counter]' />";
>> > > $tmp[] = "> > > for='department_$counter'>Department:";
>> > > $tmp[] = "> > > name='department[$counter]' />";
>> > > $tmp[] = "Title:";
>> > > $tmp[] = "> > > name='title[$counter]' />";
>> > > $tmp[] = "Email:";
>> > > $tmp[] = "> > > name='email[$counter]' />";
>> > > $tmp[] = "Phone:";
>> > >  

Re: [PHP] iterate javascript verification

2013-05-27 Thread Ken Robinson
When you do validation of the form in the same script that shows the 
form, the normal way to do this is




This won't work if you're getting to the page via another form, since 
the $_POST['submit'] is set. There two ways of avoiding this:


1) use hidden fields in each form to indicate which form was submitted
2) use a different name for each form's submit button and use that in 
the above code


Ken


At 12:52 PM 5/27/2013, Tim Dunphy wrote:

Hey guys,

Thanks for the input! This is pretty nice, and DOES work. I like the fact
that the fields have been into an iterative array. It's a very elegant
solution. However the problem with this approach is that if you load the
page directly it works. But if you call the page from the index.php page
you get an initial error on all fields as they are all quite naturally
empty when you first load the page.

Here's the index.php page. All it is is HTML, no php:

http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

  
  LDAP Request Form


  LDAP Request Form
   
Your Email Address:

How Many Forms Do You Need:


  



And here is ldap.php as was suggested:



  You will be creating $num_forms accounts
today.";
for($counter = 1;$counter<=$num_forms;$counter++) {
echo '';
echo '';
echo "Enter user: $counter";
echo "First Name:";
echo "";
echo "Last Name:";
echo "";
echo "Department:";
echo "";
echo "Title:";
echo "";
echo "Email:";
echo "";
echo "Phone:";
echo "";
  }

  echo "";
  echo "";
  echo "";
  echo "";




   ?>


Why this happens when you call the ldap.php page from index.php but not
when you load the page directly beats me. But maybe someone can shed some
light on that?

Thanks!



On Sat, May 25, 2013 at 3:45 AM, tamouse mailing lists <
tamouse.li...@gmail.com> wrote:

> On Fri, May 24, 2013 at 9:51 PM, Ken Robinson  wrote:
> > I took your code and modified it to use HTML5 validation (and few other
> > changes). You can see the results at
> > 
> http://my-testbed.com/test1/form_validation.php
> >
> > My code follows:
> >
> >>   $fields =
> > array('first_name','last_name','department','title','email','phone');
> >   $num_forms = 1;
> >   $tmp = array();
> >   $errors = array();
> >
> >
> >if (isset($_POST['submit'])) {
> > $requestor_email = $_POST['requestor_email'];
> > $num_forms  = $_POST['num_forms'];
> > for ($i = 1;$i <= $num_forms; ++$i) {
> > foreach ($fields as $fld) {
> > if ($_POST[$fld][$i] == '') {
> > $errors[] = ucwords(str_replace('_',' ',$fld)) .
> "
> > for account $i can not be blank";
> > }
> > }
> > }
> >   }
> > if (!empty($errors)) {
> > $tmp[] = "The following fields are in
> error:";
> > $tmp[] = implode("\n",$errors);
> > $tmp[] = "";
> > }
> > $tmp[] = "You will be creating
> $num_forms
> > accounts today.";
> > $tmp[] = ' > method="post" action="">';
> > $tmp[] = '';
> >
> > for($counter = 1;$counter<=$num_forms;$counter++) {
> > $tmp[] = "Enter user: $counter";
> > $tmp[] = "First
> > Name:";
> > $tmp[] = " > name='first_name[$counter]'>";
> > $tmp[] = "Last Name: />";
> > $tmp[] = " > name='last_name[$counter]' />";
> > $tmp[] = " > for='department_$counter'>Department:";
> > $tmp[] = " > name='department[$counter]' />";
> > $tmp[] = "Title:";
> > $tmp[] = " > name='title[$counter]' />";
> > $tmp[] = "Email:";
> > $tmp[] = " > name='email[$counter]' />";
> > $tmp[] = "Phone:";
> > $tmp[] = " > name='phone[$counter]' />";
> >   }
>
>
> You can DRY this up (the HTML input fields) similarly to the way you
> did the validation above...
>
> for ($i = 1;$i <= $num_forms; ++$i) {
>foreach ($fields as $fld) {
>  $tmp[]="" . ucwords(str_replace('_','
> ',$fld) . ":";
>  $tmp[]=" name='$fld[$counter]' />";
>}
> }
>
> Further, you could also check the validity of field right at the point
> of generation and issue the error right next to the field in error,
> which is usually a better UX.
>
> >   $tmp[] = " > value='$num_forms' />";
> >   $tmp[] = " name='requestor_email'
> > value='$requestor_email' />";
> >   $tmp[] = "";
> >   $tmp[] = "";
> >
> > ?>
> > 
> >
> > 
> > 
> > LDAP Form
> > 
> > 
> > 
> > 
> >
> > You will notice that I moved the code for the form to above the HTML
> > section. I believe that very little PHP should be interspersed with the
> HTML
> > -- it makes for cleaner code. You can use single quotes around form
> > attributes so you don't have to escape the double quotes. The names in
> the
> > form are now arrays. This makes your life much easier when extracting the
> > values later 

Re: [PHP] iterate javascript verification

2013-05-27 Thread Tim Dunphy
Hey guys,

Thanks for the input! This is pretty nice, and DOES work. I like the fact
that the fields have been into an iterative array. It's a very elegant
solution. However the problem with this approach is that if you load the
page directly it works. But if you call the page from the index.php page
you get an initial error on all fields as they are all quite naturally
empty when you first load the page.

Here's the index.php page. All it is is HTML, no php:

http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

  
  LDAP Request Form


  LDAP Request Form
   
Your Email Address:

How Many Forms Do You Need:


  



And here is ldap.php as was suggested:



  You will be creating $num_forms accounts
today.";
for($counter = 1;$counter<=$num_forms;$counter++) {
echo '';
echo '';
echo "Enter user: $counter";
echo "First Name:";
echo "";
echo "Last Name:";
echo "";
echo "Department:";
echo "";
echo "Title:";
echo "";
echo "Email:";
echo "";
echo "Phone:";
echo "";
  }

  echo "";
  echo "";
  echo "";
  echo "";




   ?>


Why this happens when you call the ldap.php page from index.php but not
when you load the page directly beats me. But maybe someone can shed some
light on that?

Thanks!



On Sat, May 25, 2013 at 3:45 AM, tamouse mailing lists <
tamouse.li...@gmail.com> wrote:

> On Fri, May 24, 2013 at 9:51 PM, Ken Robinson  wrote:
> > I took your code and modified it to use HTML5 validation (and few other
> > changes). You can see the results at
> > 
> http://my-testbed.com/test1/form_validation.php
> >
> > My code follows:
> >
> >>   $fields =
> > array('first_name','last_name','department','title','email','phone');
> >   $num_forms = 1;
> >   $tmp = array();
> >   $errors = array();
> >
> >
> >if (isset($_POST['submit'])) {
> > $requestor_email = $_POST['requestor_email'];
> > $num_forms  = $_POST['num_forms'];
> > for ($i = 1;$i <= $num_forms; ++$i) {
> > foreach ($fields as $fld) {
> > if ($_POST[$fld][$i] == '') {
> > $errors[] = ucwords(str_replace('_',' ',$fld)) .
> "
> > for account $i can not be blank";
> > }
> > }
> > }
> >   }
> > if (!empty($errors)) {
> > $tmp[] = "The following fields are in
> error:";
> > $tmp[] = implode("\n",$errors);
> > $tmp[] = "";
> > }
> > $tmp[] = "You will be creating
> $num_forms
> > accounts today.";
> > $tmp[] = ' > method="post" action="">';
> > $tmp[] = '';
> >
> > for($counter = 1;$counter<=$num_forms;$counter++) {
> > $tmp[] = "Enter user: $counter";
> > $tmp[] = "First
> > Name:";
> > $tmp[] = " > name='first_name[$counter]'>";
> > $tmp[] = "Last Name: />";
> > $tmp[] = " > name='last_name[$counter]' />";
> > $tmp[] = " > for='department_$counter'>Department:";
> > $tmp[] = " > name='department[$counter]' />";
> > $tmp[] = "Title:";
> > $tmp[] = " > name='title[$counter]' />";
> > $tmp[] = "Email:";
> > $tmp[] = " > name='email[$counter]' />";
> > $tmp[] = "Phone:";
> > $tmp[] = " > name='phone[$counter]' />";
> >   }
>
>
> You can DRY this up (the HTML input fields) similarly to the way you
> did the validation above...
>
> for ($i = 1;$i <= $num_forms; ++$i) {
>foreach ($fields as $fld) {
>  $tmp[]="" . ucwords(str_replace('_','
> ',$fld) . ":";
>  $tmp[]=" name='$fld[$counter]' />";
>}
> }
>
> Further, you could also check the validity of field right at the point
> of generation and issue the error right next to the field in error,
> which is usually a better UX.
>
> >   $tmp[] = " > value='$num_forms' />";
> >   $tmp[] = " name='requestor_email'
> > value='$requestor_email' />";
> >   $tmp[] = "";
> >   $tmp[] = "";
> >
> > ?>
> > 
> >
> > 
> > 
> > LDAP Form
> > 
> > 
> > 
> > 
> >
> > You will notice that I moved the code for the form to above the HTML
> > section. I believe that very little PHP should be interspersed with the
> HTML
> > -- it makes for cleaner code. You can use single quotes around form
> > attributes so you don't have to escape the double quotes. The names in
> the
> > form are now arrays. This makes your life much easier when extracting the
> > values later in PHP.
> >
> > When you check the page in a HTML5 aware brower, you will see how the
> > validation is done.
> >
> > Ken
> >
> >
> > At 10:17 PM 5/24/2013, musicdev wrote:
> >>
> >> You can validate via JS if required, for example: (JS CODE):
> >>
> >> if(element.value.length == 0){
> >>// handle 0 length value
> >> }
> >>
> >> I do agree with Ken that you SHOULD NOT perform JS validation.  It is
> >> preferable to use php or the new HTML5 fe