php-general Digest 27 May 2013 16:52:48 -0000 Issue 8248
php-general Digest 27 May 2013 16:52:48 - Issue 8248 Topics (messages 321215 through 321216): Re: Can javascript or php help with this 321215 by: dealTek Re: iterate javascript verification 321216 by: Tim Dunphy Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On May 26, 2013, at 5:48 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 5/25/2013 9:11 PM, dealTek wrote: On May 25, 2013, at 4:30 PM, Jim Giner jim.gi...@albanyhandball.com wrote: So - create another field on your form. Add an onclick event to your submit button. Have it run a js function that takes the two fields and places them into the new field. function combineFields() { var mm = document.getElementById(monthfld).value; var yy = document.getElementById('yearfld).value; document.getElementByID(mmyy).value = +mm+yy; return true; } Might have to play with this syntax to avoid the values being arithmetically added instead of concatenated, but this is one way. And of course - you could try posting on a js site instead of a php one. HTH. BTW - I see a small typo in my concat statement - 'Id', not 'ID'. -- AHA - at first it was not working but now it works like a charm - THANKS Jim - this really helps a lot!!! -- Thanks, Dave - DealTek deal...@gmail.com [db-3] ---End Message--- ---BeginMessage--- 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: html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleLDAP Request Form/title body centerh3LDAP Request Form/h3 form name=form_request method=post action=ldap.php onsubmit=return validateForm() label for=requestor_emailYour Email Address:/labelbr / input type=text required id=requestor_email name=requestor_email /br /br / label for=num_formsHow Many Forms Do You Need:/labelbr / input type=text required maxlength=2 size=5 id=num_forms name=num_forms /br /br / input type=submit name=submit value=Submit / /form/center /body /html And here is ldap.php as was suggested: body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /br /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? 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 kenrb...@rbnsn.com 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
Re: [PHP] iterate javascript verification
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: html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleLDAP Request Form/title body centerh3LDAP Request Form/h3 form name=form_request method=post action=ldap.php onsubmit=return validateForm() label for=requestor_emailYour Email Address:/labelbr / input type=text required id=requestor_email name=requestor_email /br /br / label for=num_formsHow Many Forms Do You Need:/labelbr / input type=text required maxlength=2 size=5 id=num_forms name=num_forms /br /br / input type=submit name=submit value=Submit / /form/center /body /html And here is ldap.php as was suggested: body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /br /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? 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 kenrb...@rbnsn.com 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 http://my-testbed.com/test1/form_validation.php My code follows: ?php $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:br; $tmp[] = implode(br\n,$errors); $tmp[] = br; } $tmp[] = div style='text-align:center'You will be creating $num_forms accounts today./divbr; $tmp[] = 'div style=text-align:centerform name=ldap_accounts method=post action='; $tmp[] = 'br /br /'; for($counter = 1;$counter=$num_forms;$counter++) { $tmp[] = Enter user: $counterbr /; $tmp[] = label for='first_name_$counter'First Name:/labelbr/; $tmp[] = input type='text' required id='first_name_$counter' name='first_name[$counter]'br /br /; $tmp[] = label for='last_name_$counter'Last Name:/labelbr /; $tmp[] = input type='text' required id='last_name_$counter' name='last_name[$counter]' /br /br /; $tmp[] = label for='department_$counter'Department:/labelbr/; $tmp[] =
Re: [PHP] iterate javascript verification
When you do validation of the form in the same script that shows the form, the normal way to do this is ?php 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: html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleLDAP Request Form/title body centerh3LDAP Request Form/h3 form name=form_request method=post action=ldap.php onsubmit=return validateForm() label for=requestor_emailYour Email Address:/labelbr / input type=text required id=requestor_email name=requestor_email /br /br / label for=num_formsHow Many Forms Do You Need:/labelbr / input type=text required maxlength=2 size=5 id=num_forms name=num_forms /br /br / input type=submit name=submit value=Submit / /form/center /body /html And here is ldap.php as was suggested: body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /br /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? 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 kenrb...@rbnsn.com 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 http://my-testbed.com/test1/form_validation.php My code follows: ?php $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:br; $tmp[] = implode(br\n,$errors); $tmp[] = br; } $tmp[] = div style='text-align:center'You will be creating $num_forms accounts today./divbr; $tmp[] = 'div style=text-align:centerform name=ldap_accounts method=post action='; $tmp[] = 'br /br /'; for($counter =
Re: [PHP] iterate javascript verification
Sounds good! Thanks Ken. Very clear now. Tim Sent from my iPhone On May 27, 2013, at 1:57 PM, Ken Robinson kenrb...@rbnsn.com wrote: When you do validation of the form in the same script that shows the form, the normal way to do this is ?php 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: html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleLDAP Request Form/title body centerh3LDAP Request Form/h3 form name=form_request method=post action=ldap.php onsubmit=return validateForm() label for=requestor_emailYour Email Address:/labelbr / input type=text required id=requestor_email name=requestor_email /br /br / label for=num_formsHow Many Forms Do You Need:/labelbr / input type=text required maxlength=2 size=5 id=num_forms name=num_forms /br /br / input type=submit name=submit value=Submit / /form/center /body /html And here is ldap.php as was suggested: body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /br /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? 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 kenrb...@rbnsn.com 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 http://my-testbed.com/test1/form_validation.php My code follows: ?php $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:br; $tmp[] = implode(br\n,$errors); $tmp[] = br; } $tmp[] =
[PHP] Header Keep-Alive
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] Header Keep-Alive
2013/5/27 Al n...@ridersite.org 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