[PHP] Form Submission
Hi, How can I check if a form has been submitted, I have seen a demo that uses the following: if(isset($HTTP_POST_VARS)) But I understand that $HTTP_POST_VARS is depricated... Thanks for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Submission
Shaun wrote: Hi, How can I check if a form has been submitted, I have seen a demo that uses the following: if(isset($HTTP_POST_VARS)) But I understand that $HTTP_POST_VARS is depricated... Depricated or backward compatible, depends on your view. The hot new way is to use $_POST superglobal array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form Submission
Hi, I have a form on my page. The form action is linked to itself so that the values entered will refresh the page accordingly. Is it possible to add another button to the form that utilises my JavaScript popup function and takes the values from the same form? function openQueryWindow(URL) { var args =left=150,top=100,width=742,height=402,toolbar=no,location=no,directories=n o,status=nos,menubar=no,scrollbars=yes,resizable=yes; var newWindow = window.open(URL, query, args); newWindow.focus(); } Thanks for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Submission
another button to the form that utilises my JavaScript popup function and takes the values from the same form? This is not a php question. All you need to do is loop through the form fields on you page and add them to the end of your url. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Submission
Matt M. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] another button to the form that utilises my JavaScript popup function and takes the values from the same form? This is not a php question. All you need to do is loop through the form fields on you page and add them to the end of your url. Hi, Thanks for your reply, the problem here is that if I loop through the values and them to the URL when the other button is pressed to submit the form the form action will still kink to itself rather than opening a new popup window... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Submission
Thanks for your reply, the problem here is that if I loop through the values and them to the URL when the other button is pressed to submit the form the form action will still kink to itself rather than opening a new popup window... input type=submit name=submit value=Submit onclick=return false; / that should stop form submission if they click your butto, also not much point of having that button on the page though. Anyway, this really does not have anything to do with php. Search for javascript help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Submission
Shaun wrote --- napsal:: Matt M. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] another button to the form that utilises my JavaScript popup function and takes the values from the same form? This is not a php question. All you need to do is loop through the form fields on you page and add them to the end of your url. Hi, Thanks for your reply, the problem here is that if I loop through the values and them to the URL when the other button is pressed to submit the form the form action will still kink to itself rather than opening a new popup window... How is the button defined? It should be type=button, not type=submit. And check for javascript errors, still the new window should be opened. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form submission logic
Hi all, Was wondering if someone had any idea's on this logic and if it'd work, before I tried to implement it: Within the form/form tags I have my buttons - Publish, Unpublish, New, Edit and Delete. Next I have a table of that displays a list of records from a database with a checkbox to select a particular record. Once a record has been selected they click one of the top buttons to perform their desired action. WILL this work OR do the buttons HAVE to go at the bottom? Thanks! Any help is appreciated. Regards, Aaron
Re: [PHP] form submission logic
From: Aaron Wolski [EMAIL PROTECTED] Within the form/form tags I have my buttons - Publish, Unpublish, New, Edit and Delete. Next I have a table of that displays a list of records from a database with a checkbox to select a particular record. Once a record has been selected they click one of the top buttons to perform their desired action. WILL this work OR do the buttons HAVE to go at the bottom? The buttons can go anywhere inside the form tags. Since this is a PHP list, though, you should really be asking is how would this form best work with PHP to perform each desired action? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission logic
The buttons can go anywhere inside the form tags. Since this is a PHP list, though, you should really be asking is how would this form best work with PHP to perform each desired action? ---John Holmes... Yeah, John, you're right. I should have made it more PHP related. Figured I could get away with it a slighty because PHP will be involved in the back-end processing? :) Thanks for the input everyone. A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form submission and storing variables
I'm sending information to be processed by a third party site. I need to store the inputted information in my site, via session or whatever, at some point. However, the 3rd part site only accepts the information via a POST form submission, so I can't record the variables, then redirect them to the 3rd party site via a header function. What should I do? any help would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form submission and storing variables
You can initiate a POST from within your script using cURL, assuming your php installation has cURL support enabled. Check http://www.php.net/curl for details. mh. On Mon, 10 Mar 2003, Doug Parker wrote: I'm sending information to be processed by a third party site. I need to store the inputted information in my site, via session or whatever, at some point. However, the 3rd part site only accepts the information via a POST form submission, so I can't record the variables, then redirect them to the 3rd party site via a header function. What should I do? any help would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form submission error trapping
Navid, $SCRIPT_NAME is sometimes a safer alternative than $PHP_SELF. The difference is that $PHP_SELF includes $PATH_INFO while $SCRIPT_NAME is just the name of the actual script running. http://www.php.net/manual/en/language.variables.predefined.php This becomes particularly important if you use $PATH_INFO to implement elegant (and search-engine safe) urls e.g. /search/products/myproduct rather than /search.php?category=productskey=myproduct. George Navid Yar wrote: Simply, to send a form to itself, you can use a special variable called $PHP_SELF. Here's an example of how to use it: if ($somevalue) { header(Location: $PHP_SELF); } else { execute some other code... } Here, if $somevalue holds true, it will call itself and reload the same script/file. This code is not very useful at all, but it gets the point across. If you wanted to pass GET variables to this, then you could easily say: header(Location: $PHP_SELF?var=valuevar2=value2var3=value3); ...and so on. You can also use this approach with Sessions if you wanted to turn the values back over to the form page, assuming you had two pages: one for the form, and one for form checking and entry into a database. There are several ways to check forms, whether you want it on one page or span it out to several pages. You just need to be creative in what tools are avaiable to you. Here is an example of how you can pass session values: header(Location: some_file.php??=SID?); Here, whatever variables you've registered in session_register() will be passed to the php page you specify, in this case some_file.php. Hope this helps. Have fun, and happy coding. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
Okay... I messed around with things a bit and moved the php stuff to the top as you suggested. I have part of the validation working however if more than 1 error exists, it still only prints the 1st one. Below are 2 example places where there would be an error... if I leave them both blank, they should both give an error message. $error=array(); if (strlen($username) 3) { $error['username']=Username must be more than 3 characters; } elseif (strlen($password) 3) { $error['password']=Password must be more than 3 characters; } input type=text name=username value=?=$username;? ? if ($error['username']) echo br.$error['username'];? input type=text name=password value=?=$password;? ? if ($error['password']) echo br.$error['password'];? Am I assigning errors to the array incorrectly? Thanks for your help :) Jason -Original Message- From: Jason G. [mailto:[EMAIL PROTECTED]] Sent: February 18, 2002 9:19 AM To: Matt; [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Why do not you all just put all your PHP logic, db access, etc at the TOP of the script. Once you have your results and variables created, then start into html. This method produces MUCH cleaner scripts, and there is a very minimal amount of PHP interspersed within the HTML. Also, you have time to bail out, or redirect, etc... ? Connect to DB Are we to process the form? Yes: Validate fields Generate Error Messages break; No Error Messages? Update the DB Header(Location: bla.php?NEWID=$NEWID); exit; ? html Firstname: ? if(error) echo(error message); ?br input type=text name=txtFIRSTNAME value=?= htmlspecialchars($txtFIRSTNAME); ?br br Lastname: ? if(error) echo(error message); ?br input type=text name=txtLASTNAME value=?= htmlspecialchars($txtLASTNAME); ?br br /html At 08:35 AM 2/18/2002 -0500, Matt wrote: I think that mixing of html and php is too complex and leads to hard to maintain scripts. I find it extremely difficult to understand a scripts logic when it's spread out over hundreds of lines of php/html. I use EasyTemplates that came in Web Applications Development with PHP 4.0 by Tobias Ratschiller and Till Gerkin. It looks like the source is copyrighted and you have to buy the book to get it. But it says it's based on FastTemplates. The book itself is at http://www.amazon.com/exec/obidos/ASIN/0735709971/ You can see a sample of the method here http://marc.theaimsgroup.com/?l=php-generalm=101371611609042w=2 Notice that the form action handler is the same as the original form. This is a simple example, but it does remember user input as you want. I wrote a couple of helper functions that accept db names to build select boxes and radio buttons. They return strings of the html with the selected value, and I just put them in a template container reserved for them (the {TEMPLATE_ITEM} in the sample). For tables with unknown number of rows, I have one template of the main page, one for the table container, and one for each row itself. I loop on the row, using the row template and concatenate all of the rows of html into a string. I take that string and stick it into the table template, and finally stick the table into the page template. Very smooth, easy to read, and no trouble with headers() since all output is done on the last statement. You have complete control over the script until then, and can bail out to another page, or decide to use other templates and output something else. As for errors, I build an array of the messages such as: if (!empty($thatsThere)) { $errors[] = Don't put $thatsThere in there; } if (empty($userName)) { $errors[] = Username must be supplied; } Then you can tell if all is okay, with if (is_array($errors)). If it is an array, then something is wrong, so I append the array contests into html like this: foreach($errors as $value) { $errorMsgs = $value . br\n; } and then put $errorMsgs into the page template container you've reserved for it. - Original Message - From: Jason Dulberg [EMAIL PROTECTED] To: [EMAIL PROTECTED] I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some
RE: [PHP] form submission error trapping
George, Good point. I actually like your idea a lot. I have never thought about using $SCRIPT_NAME. You also mentioned using $PATH_INFO to implement elegant (and search-engine safe) urls... below. Can you give me a couple of examples of how I might do this? I always hated the GET strings at the end of the url. Sometimes I redirect a user to the same page two times just to get rid of the trailing GET string. I know that's a bad way of doing it, but it was a temporary thing until I could find a way around it. I would really appreciate your help on this one. Thanks... Navid -Original Message- From: George Whiffen [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 7:09 AM To: Navid Yar Subject: Re: [PHP] form submission error trapping Navid, $SCRIPT_NAME is sometimes a safer alternative than $PHP_SELF. The difference is that $PHP_SELF includes $PATH_INFO while $SCRIPT_NAME is just the name of the actual script running. http://www.php.net/manual/en/language.variables.predefined.php This becomes particularly important if you use $PATH_INFO to implement elegant (and search-engine safe) urls e.g. /search/products/myproduct rather than /search.php?category=productskey=myproduct. George Navid Yar wrote: Simply, to send a form to itself, you can use a special variable called $PHP_SELF. Here's an example of how to use it: if ($somevalue) { header(Location: $PHP_SELF); } else { execute some other code... } Here, if $somevalue holds true, it will call itself and reload the same script/file. This code is not very useful at all, but it gets the point across. If you wanted to pass GET variables to this, then you could easily say: header(Location: $PHP_SELF?var=valuevar2=value2var3=value3); ...and so on. You can also use this approach with Sessions if you wanted to turn the values back over to the form page, assuming you had two pages: one for the form, and one for form checking and entry into a database. There are several ways to check forms, whether you want it on one page or span it out to several pages. You just need to be creative in what tools are avaiable to you. Here is an example of how you can pass session values: header(Location: some_file.php??=SID?); Here, whatever variables you've registered in session_register() will be passed to the php page you specify, in this case some_file.php. Hope this helps. Have fun, and happy coding. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
Here's what I did. $error = ; if (error_in_field_1) $error .= A; if (error_in_field_2) $error .= B; if (error_in_field_3) $error .= C; and so on. Then, when displaying the form... if (strstr($error,A)) { echo You forgot to fill in this fieldbr\n; } echo input type=\text\ name=\Whatever\ value=\$whatever\; etc. -Original Message- From: Jason Dulberg [SMTP:[EMAIL PROTECTED]] Sent: Sunday, February 17, 2002 23:40 To: Martin Towell Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping RE: [PHP] form submission error trappingThanks for the code Is there a way to keep track of what fields had the errors as its possible for people to have like 5 errors? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form submission error trapping
I think that mixing of html and php is too complex and leads to hard to maintain scripts. I find it extremely difficult to understand a scripts logic when it's spread out over hundreds of lines of php/html. I use EasyTemplates that came in Web Applications Development with PHP 4.0 by Tobias Ratschiller and Till Gerkin. It looks like the source is copyrighted and you have to buy the book to get it. But it says it's based on FastTemplates. The book itself is at http://www.amazon.com/exec/obidos/ASIN/0735709971/ You can see a sample of the method here http://marc.theaimsgroup.com/?l=php-generalm=101371611609042w=2 Notice that the form action handler is the same as the original form. This is a simple example, but it does remember user input as you want. I wrote a couple of helper functions that accept db names to build select boxes and radio buttons. They return strings of the html with the selected value, and I just put them in a template container reserved for them (the {TEMPLATE_ITEM} in the sample). For tables with unknown number of rows, I have one template of the main page, one for the table container, and one for each row itself. I loop on the row, using the row template and concatenate all of the rows of html into a string. I take that string and stick it into the table template, and finally stick the table into the page template. Very smooth, easy to read, and no trouble with headers() since all output is done on the last statement. You have complete control over the script until then, and can bail out to another page, or decide to use other templates and output something else. As for errors, I build an array of the messages such as: if (!empty($thatsThere)) { $errors[] = Don't put $thatsThere in there; } if (empty($userName)) { $errors[] = Username must be supplied; } Then you can tell if all is okay, with if (is_array($errors)). If it is an array, then something is wrong, so I append the array contests into html like this: foreach($errors as $value) { $errorMsgs = $value . br\n; } and then put $errorMsgs into the page template container you've reserved for it. - Original Message - From: Jason Dulberg [EMAIL PROTECTED] To: [EMAIL PROTECTED] I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form submission error trapping
Why do not you all just put all your PHP logic, db access, etc at the TOP of the script. Once you have your results and variables created, then start into html. This method produces MUCH cleaner scripts, and there is a very minimal amount of PHP interspersed within the HTML. Also, you have time to bail out, or redirect, etc... ? Connect to DB Are we to process the form? Yes: Validate fields Generate Error Messages break; No Error Messages? Update the DB Header(Location: bla.php?NEWID=$NEWID); exit; ? html Firstname: ? if(error) echo(error message); ?br input type=text name=txtFIRSTNAME value=?= htmlspecialchars($txtFIRSTNAME); ?br br Lastname: ? if(error) echo(error message); ?br input type=text name=txtLASTNAME value=?= htmlspecialchars($txtLASTNAME); ?br br /html At 08:35 AM 2/18/2002 -0500, Matt wrote: I think that mixing of html and php is too complex and leads to hard to maintain scripts. I find it extremely difficult to understand a scripts logic when it's spread out over hundreds of lines of php/html. I use EasyTemplates that came in Web Applications Development with PHP 4.0 by Tobias Ratschiller and Till Gerkin. It looks like the source is copyrighted and you have to buy the book to get it. But it says it's based on FastTemplates. The book itself is at http://www.amazon.com/exec/obidos/ASIN/0735709971/ You can see a sample of the method here http://marc.theaimsgroup.com/?l=php-generalm=101371611609042w=2 Notice that the form action handler is the same as the original form. This is a simple example, but it does remember user input as you want. I wrote a couple of helper functions that accept db names to build select boxes and radio buttons. They return strings of the html with the selected value, and I just put them in a template container reserved for them (the {TEMPLATE_ITEM} in the sample). For tables with unknown number of rows, I have one template of the main page, one for the table container, and one for each row itself. I loop on the row, using the row template and concatenate all of the rows of html into a string. I take that string and stick it into the table template, and finally stick the table into the page template. Very smooth, easy to read, and no trouble with headers() since all output is done on the last statement. You have complete control over the script until then, and can bail out to another page, or decide to use other templates and output something else. As for errors, I build an array of the messages such as: if (!empty($thatsThere)) { $errors[] = Don't put $thatsThere in there; } if (empty($userName)) { $errors[] = Username must be supplied; } Then you can tell if all is okay, with if (is_array($errors)). If it is an array, then something is wrong, so I append the array contests into html like this: foreach($errors as $value) { $errorMsgs = $value . br\n; } and then put $errorMsgs into the page template container you've reserved for it. - Original Message - From: Jason Dulberg [EMAIL PROTECTED] To: [EMAIL PROTECTED] I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form submission error trapping
I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
submit back to the same page - or include that page Martin -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 9:23 AM To: [EMAIL PROTECTED] Subject: [PHP] form submission error trapping I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form submission error trapping
Jason, I just finished one of my form pages, and I'm really happy with how it turned out. I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. If you want, I can send you a link to my test site so you can check it out. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
Ya, it would be cool if you could how do you submit the form to itself? Right now, I have something like if (!$submit) { display form } else { process if (trim($email)==) { echo error, hit back button to fix; } } Thanks Jason -Original Message- From: Steven Walker [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:18 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Jason, I just finished one of my form pages, and I'm really happy with how it turned out. I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. If you want, I can send you a link to my test site so you can check it out. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
something like: ? // filename: here.html if ($submit) { $error = false; if (trim($email) == ) { $error = true; } // process more... if (!$error) { // do stuff here, maybe a header(location:); exit; } } ? html form action=here.html method=post input type=text name=email value=?= $email; ? input type=submit name=submit value=Go For It!!! /form /html not tested but should work - just expand on it Martin -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 10:22 AM To: Steven Walker Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping Ya, it would be cool if you could how do you submit the form to itself? Right now, I have something like if (!$submit) { display form } else { process if (trim($email)==) { echo error, hit back button to fix; } } Thanks Jason -Original Message- From: Steven Walker [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:18 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Jason, I just finished one of my form pages, and I'm really happy with how it turned out. I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. If you want, I can send you a link to my test site so you can check it out. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
-Original Message- From: Steven Walker [mailto:[EMAIL PROTECTED]] I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. Only catch is, you have to build all that logic to populate your fields. Piece of cake when you have a simple form, not so easy when you have a dynamically-generated form (with a variable number of inputs) including multi-select buttons and the like. I guess the real challenge is converting a pre-existing page like the one I've described into one that can re-populate itself on an error condition. Building it that way from scratch is merely a programming task. - Ken [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
RE: [PHP] form submission error trappingThanks for the code Is there a way to keep track of what fields had the errors as its possible for people to have like 5 errors? Thanks again. Jason -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:41 PM To: '[EMAIL PROTECTED]'; Steven Walker Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping something like: ? // filename: here.html if ($submit) { $error = false; if (trim($email) == ) { $error = true; } // process more... if (!$error) { // do stuff here, maybe a header(location:); exit; } } ? html form action=here.html method=post input type=text name=email value=?= $email; ? input type=submit name=submit value=Go For It!!! /form /html not tested but should work - just expand on it Martin -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 10:22 AM To: Steven Walker Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping Ya, it would be cool if you could how do you submit the form to itself? Right now, I have something like if (!$submit) { display form } else { process if (trim($email)==) { echo error, hit back button to fix; } } Thanks Jason -Original Message- From: Steven Walker [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:18 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Jason, I just finished one of my form pages, and I'm really happy with how it turned out. I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. If you want, I can send you a link to my test site so you can check it out. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form submission error trapping
I guess the real challenge is converting a pre-existing page like the one I've described into one that can re-populate itself on an error condition. Building it that way from scratch is merely a programming task. That's true, however there are a few ways to cheat :). For example, in my form I have a State and Country popup menu. Rather than trying to write code that selects the proper one to match the post data, I simply create a new entry at the top: select name=state ? if(isset($state)) { $statename = GetStateName($state); echo option selected value='$state'$statename; } ? option value=Select a state option value=ALAlabama This works because I've already verified the data. If the data doesn't pass verification, it would be reset and would fail the isset($state) test. Otherwise, most form elements are pretty easy to assign values to. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 03:42 PM, Ken wrote: -Original Message- From: Steven Walker [mailto:[EMAIL PROTECTED]] I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. Only catch is, you have to build all that logic to populate your fields. Piece of cake when you have a simple form, not so easy when you have a dynamically-generated form (with a variable number of inputs) including multi-select buttons and the like. I guess the real challenge is converting a pre-existing page like the one I've described into one that can re-populate itself on an error condition. Building it that way from scratch is merely a programming task. - Ken [EMAIL PROTECTED]
RE: [PHP] form submission error trapping
sure - $error could be an array, so the code I supplied could be changed to: if you're email client supports rich text, then the changed lines are in green ? // filename: here.html if ($submit) { $error = array(); if (trim($email) == ) { $error[email] = true; } // process more... if (count($error) == 0) { // do stuff here, maybe a header(location:); exit; } } ? html form action=here.html method=post ? if ($error[email]) echo Error: please fill in your email address; ? input type=text name=email value=?= $email; ? input type=submit name=submit value=Go For It!!! /form /html -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 10:40 AM To: Martin Towell Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping Thanks for the code Is there a way to keep track of what fields had the errors as its possible for people to have like 5 errors? Thanks again. Jason -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:41 PM To: '[EMAIL PROTECTED]'; Steven Walker Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping something like: ? // filename: here.html if ($submit) { $error = false; if (trim($email) == ) { $error = true; } // process more... if (!$error) { // do stuff here, maybe a header(location:); exit; } } ? html form action=here.html method=post input type=text name=email value=?= $email; ? input type=submit name=submit value=Go For It!!! /form /html not tested but should work - just expand on it Martin -Original Message- From: Jason Dulberg [ mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 10:22 AM To: Steven Walker Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping Ya, it would be cool if you could how do you submit the form to itself? Right now, I have something like if (!$submit) { display form } else { process if (trim($email)==) { echo error, hit back button to fix; } } Thanks Jason -Original Message- From: Steven Walker [ mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:18 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Jason, I just finished one of my form pages, and I'm really happy with how it turned out. I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. If you want, I can send you a link to my test site so you can check it out. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net http://extreme.nas.net -- PHP General Mailing List ( http://www.php.net/ http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.php.net/unsub.php -- PHP General Mailing List ( http://www.php.net/ http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.php.net/unsub.php
Re: [PHP] form submission error trapping
Yeah, for buttons (radio/checkboxes) I had to put an if statement on each one: td width=84% input type=radio name=formatting value=unformatted ? if($format == unformatted) echo checked; ? unformatted input type=radio name=formatting value=table ? if($format == table) echo checked; ? You're right... it's not as easy. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
Simply, to send a form to itself, you can use a special variable called $PHP_SELF. Here's an example of how to use it: if ($somevalue) { header(Location: $PHP_SELF); } else { execute some other code... } Here, if $somevalue holds true, it will call itself and reload the same script/file. This code is not very useful at all, but it gets the point across. If you wanted to pass GET variables to this, then you could easily say: header(Location: $PHP_SELF?var=valuevar2=value2var3=value3); ...and so on. You can also use this approach with Sessions if you wanted to turn the values back over to the form page, assuming you had two pages: one for the form, and one for form checking and entry into a database. There are several ways to check forms, whether you want it on one page or span it out to several pages. You just need to be creative in what tools are avaiable to you. Here is an example of how you can pass session values: header(Location: some_file.php??=SID?); Here, whatever variables you've registered in session_register() will be passed to the php page you specify, in this case some_file.php. Hope this helps. Have fun, and happy coding. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php