Re: [PHP] Self-Process php forms or not?
On Oct 5, 2009, at 7:42 PM, Manuel Lemos wrote: Hello, on 10/05/2009 03:02 PM Philip Thompson said the following: I try to avoid the use of hidden form elements as much as possible, especially for tracking whether a user has submitted a form or not... I use name=submit for the submit button instead, that will pass the value of the submit button to the action script. above all i use a template engine, smarty to take care of the presentation for me(like deciding whether to show the form and/or a success/failure message) That only works if the user clicks on that submit button. If the user hits the enter key in a text input, the form is submitted but the submit input variable is not set. That is why an hidden input is a safer solution. If you need the button to be *clicked*... form onsubmit=$('submitButton').fireEvent('click'); ... Or something along those lines. That does not make much sense and is pointless. First that syntax you mentioned probably requires JQuery or some other large Javascript library. something like this['submitButton'].click() would emulate the click event. Second, by the time that onsubmit is called, the event that triggered it was already dispatched. Emulating the click on a button would probably fire the form submission and onsubmit code would be run again, leading to an infinite loop sucking machine CPU. It makes perfect sense and is not pointless. Yes, it is library- specific javascript. However, it was used to show an example and make a point. I assume that most the subscribers here are able to decipher the code and determine what the intent was. And no, this will not cause an infinite loop. The onsubmit is called first and will process whatever action you specify, and then move on. *If* the submit button wasn't *clicked* and you needed it to be, then this would emulate that functionality. I'm not saying this is the best solution on how to deal with the previous question but it is *a* solution. Here's some code that you can see there's no infinite loop and shows which events are called first. -- ?php session_start(); $_SESSION['timesSubmitted'] = isset ($_POST['submitted']) ? $_SESSION['timesSubmitted'] + 1 : 0; ? html head titleloop? i don#039;t think so/title /head body h3Times submitted: ?php echo $_SESSION['timesSubmitted']; ?/h3 form action=?php echo $_SERVER['PHP_SELF']; ? method=post name=theForm onsubmit=document.getElementById('submitBtn').click(); return false; input type=hidden name=submitted value=1 / input type=text name=text value=Focus on me and hit Enter / br/ input type=button name=submitBtn id=submitBtn value=Click me to Submit onclick=alert('I was clicked'); document.theForm.submit (); / /form script type=text/javascriptdocument.theForm.text.focus();/script /body /html -- The above code works as expected in Safari 4.0.3, FF3.5.3 and IE8. Cheers, ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
At 7:25 PM +0100 10/4/09, MEM wrote: Unfortunately, I'm really REALLY on a rush. I saw a bumper sticker the other day which read: Humpty Dumpty was rushed Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On Oct 2, 2009, at 3:00 AM, Manuel Lemos wrote: Hello, on 10/02/2009 04:41 AM kranthi said the following: I try to avoid the use of hidden form elements as much as possible, especially for tracking whether a user has submitted a form or not... I use name=submit for the submit button instead, that will pass the value of the submit button to the action script. above all i use a template engine, smarty to take care of the presentation for me(like deciding whether to show the form and/or a success/failure message) That only works if the user clicks on that submit button. If the user hits the enter key in a text input, the form is submitted but the submit input variable is not set. That is why an hidden input is a safer solution. If you need the button to be *clicked*... form onsubmit=$('submitButton').fireEvent('click'); ... Or something along those lines. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
Hello, on 10/05/2009 03:02 PM Philip Thompson said the following: I try to avoid the use of hidden form elements as much as possible, especially for tracking whether a user has submitted a form or not... I use name=submit for the submit button instead, that will pass the value of the submit button to the action script. above all i use a template engine, smarty to take care of the presentation for me(like deciding whether to show the form and/or a success/failure message) That only works if the user clicks on that submit button. If the user hits the enter key in a text input, the form is submitted but the submit input variable is not set. That is why an hidden input is a safer solution. If you need the button to be *clicked*... form onsubmit=$('submitButton').fireEvent('click'); ... Or something along those lines. That does not make much sense and is pointless. First that syntax you mentioned probably requires JQuery or some other large Javascript library. something like this['submitButton'].click() would emulate the click event. Second, by the time that onsubmit is called, the event that triggered it was already dispatched. Emulating the click on a button would probably fire the form submission and onsubmit code would be run again, leading to an infinite loop sucking machine CPU. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
Thanks a lot. To all. For the moment, I'm with the redirect solution that others have pointed. But after seen tedd example and watch Manuel videos, I'm starting to understand how the hidden field solution work as well. Well... I'm *starting* to understand I've not fully understand it yet, despite all your great examples. Because the structure of the code with hidden fields, seems quite different from the structure I have right now and I'm unable to make the switch. Here is the actual structure: if (isset($_POST['submit'])) { //declare variables $var = $_POST['var']; etc... //validate //process the form (send e-mail or save to database etc...) //redirect to success page. } else { Echo Sorry, couldn't process the form; } html form I suppose that the echo message telling we couldn't process the form does not appear when the form first loads, because the server side script is not requested on load, it is requested when the form submits to the php code presented on that same page (self). Tom Worster, is this precise? In the future, I will print tedd example, and Manuel scheme, and try to change the code above to accommodate hidden fields, because I still prefer having only one file. Thank you all once again, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On 10/4/09 9:25 AM, MEM tal...@gmail.com wrote: Thanks a lot. To all. For the moment, I'm with the redirect solution that others have pointed. But after seen tedd example and watch Manuel videos, I'm starting to understand how the hidden field solution work as well. Well... I'm *starting* to understand I've not fully understand it yet, despite all your great examples. Because the structure of the code with hidden fields, seems quite different from the structure I have right now and I'm unable to make the switch. Here is the actual structure: if (isset($_POST['submit'])) { //declare variables $var = $_POST['var']; etc... //validate //process the form (send e-mail or save to database etc...) //redirect to success page. } else { Echo Sorry, couldn't process the form; } html form I suppose that the echo message telling we couldn't process the form does not appear when the form first loads, because the server side script is not requested on load, it is requested when the form submits to the php code presented on that same page (self). Tom Worster, is this precise? i don't think so. if the user requests the page a_form.php then the server will normally execute the a_form.php script regardless whether the form was submitted or not. to display a blank form, the user probably requests a_form.php with the GET method and probably without any GET parameters. the script will run but $_POST['submit'] is not set. so the script you show above will echo Sorry, couldn't process the form. that will likely confuse the user. in your structure you branch only two ways. i think you need three ways: 1 - the user simply arrived at the form. there is no POST data. the form was not submitted. 2 - there is POST data. the form was submitted. 2a - the POST data is unacceptable. 2b - the POST data is good. in branches 1 and 2a you send the form. in 2b, you send some other page or a redirect. in 1 you send the form blank. in 2a you might fill some form elements with data from POST and add some annotations to the form so the user knows what she or he did wrong. In the future, I will print tedd example, and Manuel scheme, and try to change the code above to accommodate hidden fields, because I still prefer having only one file. one can learn a lot reading other people's code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
i don't think so. if the user requests the page a_form.php then the server will normally execute the a_form.php script regardless whether the form was submitted or not. to display a blank form, the user probably requests a_form.php with the GET method and probably without any GET parameters. the script will run but $_POST['submit'] is not set. so the script you show above will echo Sorry, couldn't process the form. that will likely confuse the user. Ok... but please have a look here, I've uploaded and tested that code, and I can assure you that the message doesn't appear when the form first load: http://pastebin.com/m21078fe3 Note: if you use: copy to clipboard option the numbers will gone. Regards, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
At 3:39 PM +0100 10/4/09, MEM wrote: i don't think so. if the user requests the page a_form.php then the server will normally execute the a_form.php script regardless whether the form was submitted or not. to display a blank form, the user probably requests a_form.php with the GET method and probably without any GET parameters. the script will run but $_POST['submit'] is not set. so the script you show above will echo Sorry, couldn't process the form. that will likely confuse the user. Ok... but please have a look here, I've uploaded and tested that code, and I can assure you that the message doesn't appear when the form first load: http://pastebin.com/m21078fe3 Note: if you use: copy to clipboard option the numbers will gone. Regards, Márcio The problem, as I see it, is that you are not willing to write a simple example and get that to work. Instead, you complicate things beyond your ability to understand. My advice, step back -- write a simple example that does what you want and then expand it. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On 10/4/09 10:39 AM, MEM tal...@gmail.com wrote: i don't think so. if the user requests the page a_form.php then the server will normally execute the a_form.php script regardless whether the form was submitted or not. to display a blank form, the user probably requests a_form.php with the GET method and probably without any GET parameters. the script will run but $_POST['submit'] is not set. so the script you show above will echo Sorry, couldn't process the form. that will likely confuse the user. Ok... but please have a look here, I've uploaded and tested that code, and I can assure you that the message doesn't appear when the form first load: http://pastebin.com/m21078fe3 Note: if you use: copy to clipboard option the numbers will gone. this has a different structure from what you showed us in your email earlier today (Sunday, October 4, 2009 9:25 AM). this script has the structure: ?php $erros=array(); if(isset($_POST['submit'])) { ... if (!$erros) { ... // all done, now redirect: Redireciona(gracias.html); } else { echo (Sorry. The form couldn't be processed.); } } ? as i said before, a script will execute regardless. but this new script fragment does nothing except initialize $erros if $_POST['submit'] is not set (e.g. if the user requests the page without POSTing the form). i don't see a problem. this script also has the three cases i described clearly separated. now, what was your question? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On 10/4/09 10:55 AM, tedd tedd.sperl...@gmail.com wrote: At 3:39 PM +0100 10/4/09, MEM wrote: i don't think so. if the user requests the page a_form.php then the server will normally execute the a_form.php script regardless whether the form was submitted or not. to display a blank form, the user probably requests a_form.php with the GET method and probably without any GET parameters. the script will run but $_POST['submit'] is not set. so the script you show above will echo Sorry, couldn't process the form. that will likely confuse the user. Ok... but please have a look here, I've uploaded and tested that code, and I can assure you that the message doesn't appear when the form first load: http://pastebin.com/m21078fe3 Note: if you use: copy to clipboard option the numbers will gone. Regards, Márcio The problem, as I see it, is that you are not willing to write a simple example and get that to work. Instead, you complicate things beyond your ability to understand. My advice, step back -- write a simple example that does what you want and then expand it. i agree that it does seem a bit as though Márcio is in such a hurry to make something work that the tasks of learning and understanding the fundamentals are being left aside. while that's maybe understandable, it's a bit frustrating when we're trying to explain the fundamentals. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
i agree that it does seem a bit as though Márcio is in such a hurry to make something work that the tasks of learning and understanding the fundamentals are being left aside. while that's maybe understandable, it's a bit frustrating when we're trying to explain the fundamentals. Thanks a lot. Tedd, Tom, I perfectly understand. I can only apologize. Unfortunately, I'm really REALLY on a rush. But as an additional information, I'm marking all this e-mails for latter reference and study. as i said before, a script will execute regardless. but this new script fragment does nothing except initialize $erros if $_POST['submit'] is not set (e.g. if the user requests the page without POSTing the form). i don't see a problem. this script also has the three cases i described clearly separated. now, what was your question? None. I've not properly see the structure that I was in, and according to that mistake, I've taking wrong conclusions. But thanks for pointing it out. Regards and, once again, thanks for your feedback, and I'm really sorry for not been able to properly learn with your advices. :s Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On 10/2/09 10:24 AM, tedd tedd.sperl...@gmail.com wrote: At 1:55 PM +0530 10/2/09, kranthi wrote: and yes i forgot to mention... i avoid hidden form elements because they can be modified very easily and hence pose a security threat. That depends upon how sloppy you are in coding. NONE of my hidden variables pose any security problems whatsoever. ...because one always assumes that data supplied in an http request is tainted. hence arguments about which exploit is more likely is rather pointless. a hidden input is really no different from any other form field. kranthi's argument would be consistent if he felt that all form inputs should be avoided because they are so easily modified as to pose a security threat. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
At 7:11 PM +0100 10/2/09, MEM wrote: I don't want to take another path. The hidden fields seems the way to go. However, you gave me the example above, and I'm not understanding how can I pass from your example: A multi-step form. To what I was looking form: 1 step form with a success page that shows no form elements. Sorry if I've not understand. I was having no intention of doing so. Regards, Márcio Márcio: At some point here, you must take keyboard in hand and program this yourself. If you took my code and ran it, then you would understand. Here's a working example: http://www.webbytedd.com/aa/step-form/ This only one of many ways to solve your problem, but it does solve it. Cheers, tedd PS: Please reply to the list and not me privately, unless you are hiring me (learned that from Stut) -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
At 9:42 AM -0400 10/3/09, Tom Worster wrote: On 10/2/09 10:24 AM, tedd tedd.sperl...@gmail.com wrote: At 1:55 PM +0530 10/2/09, kranthi wrote: and yes i forgot to mention... i avoid hidden form elements because they can be modified very easily and hence pose a security threat. That depends upon how sloppy you are in coding. NONE of my hidden variables pose any security problems whatsoever. ...because one always assumes that data supplied in an http request is tainted. hence arguments about which exploit is more likely is rather pointless. a hidden input is really no different from any other form field. kranthi's argument would be consistent if he felt that all form inputs should be avoided because they are so easily modified as to pose a security threat. Exactly. All data gathered via forms, hidden or not, must be sanitized. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On 10/2/09 10:06 AM, MEM tal...@gmail.com wrote: I'm now understanding that even if the form is submitted to self, we can still use a redirect to a success_message_page.php. However, we must do this redirect, AFTER the form has submitted to himself. It's the only thing that we have to pay attention here, correct? Since we are not dealing with a confirmation page, or a multi-step form, the hidden field isn't necessary. It's this correct assumptions? the server script that runs in response to an http request for uri X can determine if conditions of success are met only after the server receives the request for X. so, if i understand your question, yes. i think your terminology is confusing you, e.g.: AFTER the form has submitted to himself. a form doesn't submit to itself. a form and a script that processes it are SEPARATE THINGS. it's better to think in terms of a user agent and a server communicating with http requests and responses. the UA sends http requests for uris X, Y, Z, etc. (with or without accompanying form data). the forms are part of html pages the server sends to the UA in http responses. a user drives the UA. PHP scripts are involved in the server's generation of responses. (a diagram might help.) now to your queston: if a UA has an html page that it got in a response for uri X; and if the page has a form; and if the form has no action attribute (or action=X); and if the user submits the form; then the UA will send the server an http request for X. next the server receives the request for X and the server runs a certain script, the php script you are coding. now i'm assuming these are your requirements: if that script determines failure, the user says at X and is asked to resubmit the form. if the script determines success, the user will wind up at a new uri: Y. further, you want to send the user over to Y by sending her UA an http response with Location=Y redirection. in these terms, the answer to your question should be pretty clear. your script has to receive and process requests for X before it can decide if it's going to respond to the UA with a Location=Y redirection or an html page with a form and an error message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
I try to avoid the use of hidden form elements as much as possible, especially for tracking whether a user has submitted a form or not... I use name=submit for the submit button instead, that will pass the value of the submit button to the action script. above all i use a template engine, smarty to take care of the presentation for me(like deciding whether to show the form and/or a success/failure message) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
Hello, on 10/02/2009 04:41 AM kranthi said the following: I try to avoid the use of hidden form elements as much as possible, especially for tracking whether a user has submitted a form or not... I use name=submit for the submit button instead, that will pass the value of the submit button to the action script. above all i use a template engine, smarty to take care of the presentation for me(like deciding whether to show the form and/or a success/failure message) That only works if the user clicks on that submit button. If the user hits the enter key in a text input, the form is submitted but the submit input variable is not set. That is why an hidden input is a safer solution. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
That only works if the user clicks on that submit button. If the user hits the enter key in a text input, the form is submitted but the submit input variable is not set. That is why an hidden input is a safer solution. i doubt that, because i use the above mentioned method in nearly all of my projects, and all of them are working fine. P.S: i prefer keyboard to mouse as a input device -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
and yes i forgot to mention... i avoid hidden form elements because they can be modified very easily and hence pose a security threat. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On Fri, 2009-10-02 at 13:55 +0530, kranthi wrote: and yes i forgot to mention... i avoid hidden form elements because they can be modified very easily and hence pose a security threat. You say you don't use hidden fields because they can be modified too easily, yet you say you check for the submit button? Which out of the two do you do, as last time I checked, modifying one form field is as easy as changing any other! Also worth noting, you can only successfully check for the name=submit value if there is only one submit button in your form, as that is then the default (and only) submit that the form can use, so it uses that. If you have more than one submit button (and this includes image input elements) then using the keyboard will use the first submit field it finds I believe. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
You say you don't use hidden fields because they can be modified too easily, yet you say you check for the submit button? Which out of the two do you do, as last time I checked, modifying one form field is as easy as changing any other! I completely agree with you. changing submit text is as easy as changing hidden fields, but its less likely for a user to modify a submit button as compared to a hidden field. moreover it just reduces my typing load. (This is just my practice) Also worth noting, you can only successfully check for the name=submit value if there is only one submit button in your form, as that is then the default (and only) submit that the form can use, so it uses that. If you have more than one submit button (and this includes image input elements) then using the keyboard will use the first submit field it finds I believe. Cant agree with you on this though. as far as i know using name= (names of the two buttons may/may not be unique) is the only way to track form submission for forms with multiple submit buttons. Please point out if you think otherwise -- Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
I want to apologize to you all. I have mentioned two things on the same basket, but it was not appropriate. Since a confirmation page is not the same thing as a success page. Let's forget about the confirmation page, since it's not required. I'm now understanding that even if the form is submitted to self, we can still use a redirect to a success_message_page.php. However, we must do this redirect, AFTER the form has submitted to himself. It's the only thing that we have to pay attention here, correct? Since we are not dealing with a confirmation page, or a multi-step form, the hidden field isn't necessary. It's this correct assumptions? Please advice, Regards, Márcio -Original Message- From: kranthi [mailto:kranthi...@gmail.com] Sent: sexta-feira, 2 de Outubro de 2009 11:12 To: a...@ashleysheridan.co.uk Cc: Manuel Lemos; php-general@lists.php.net; MEM; Bob McConnell Subject: Re: [PHP] Self-Process php forms or not? You say you don't use hidden fields because they can be modified too easily, yet you say you check for the submit button? Which out of the two do you do, as last time I checked, modifying one form field is as easy as changing any other! I completely agree with you. changing submit text is as easy as changing hidden fields, but its less likely for a user to modify a submit button as compared to a hidden field. moreover it just reduces my typing load. (This is just my practice) Also worth noting, you can only successfully check for the name=submit value if there is only one submit button in your form, as that is then the default (and only) submit that the form can use, so it uses that. If you have more than one submit button (and this includes image input elements) then using the keyboard will use the first submit field it finds I believe. Cant agree with you on this though. as far as i know using name= (names of the two buttons may/may not be unique) is the only way to track form submission for forms with multiple submit buttons. Please point out if you think otherwise -- Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
At 1:55 PM +0530 10/2/09, kranthi wrote: and yes i forgot to mention... i avoid hidden form elements because they can be modified very easily and hence pose a security threat. That depends upon how sloppy you are in coding. NONE of my hidden variables pose any security problems whatsoever. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
At 3:06 PM +0100 10/2/09, MEM wrote: I want to apologize to you all. I have mentioned two things on the same basket, but it was not appropriate. Since a confirmation page is not the same thing as a success page. Let's forget about the confirmation page, since it's not required. I'm now understanding that even if the form is submitted to self, we can still use a redirect to a success_message_page.php. However, we must do this redirect, AFTER the form has submitted to himself. It's the only thing that we have to pay attention here, correct? Since we are not dealing with a confirmation page, or a multi-step form, the hidden field isn't necessary. It's this correct assumptions? Please advice, Regards, Márcio You can set it up any number of ways. There is no absolute need for a redirect. Everything can be done in one form, or not -- your choice. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
You can set it up any number of ways. There is no absolute need for a redirect. Everything can be done in one form, or not -- your choice. Cheers, tedd Yes. But since I don't want to display a success information + form fields, but only the success information, I believe the only way we have to do this is by either use javascript and update a div or similar, or using only php, by redirecting to another page. Is this correct? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
At 3:35 PM +0100 10/2/09, MEM wrote: You can set it up any number of ways. There is no absolute need for a redirect. Everything can be done in one form, or not -- your choice. Cheers, tedd Yes. But since I don't want to display a success information + form fields, but only the success information, I believe the only way we have to do this is by either use javascript and update a div or similar, or using only php, by redirecting to another page. Is this correct? No -- and you are not listening. I gave you the way to do it, but you are taking another path. As always, it's your choice. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
Yes. But since I don't want to display a success information + form fields, but only the success information, I believe the only way we have to do this is by either use javascript and update a div or similar, or using only php, by redirecting to another page. Is this correct? Whether or not it's the only way, redirecting to a success page is probably the best way, from a user-experience perspective. It keeps the browser history sane and avoids possible trouble with page-refreshes. Google for post redirect get and you'll find all sorts of discussions of this pattern. Here's one of the clearer articles that came up on the first page of results, when I ran that search: http://www.andypemberton.com/engineering/the-post-redirect-get-pattern/ Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
Hello, on 10/02/2009 05:23 AM kranthi said the following: That only works if the user clicks on that submit button. If the user hits the enter key in a text input, the form is submitted but the submit input variable is not set. That is why an hidden input is a safer solution. i doubt that, because i use the above mentioned method in nearly all of my projects, and all of them are working fine. P.S: i prefer keyboard to mouse as a input device Sorry, what I meant is that if you have multiple submit buttons in your form, say Preview, Save and Cancel, if you hit enter in a text input it will not set the variables for all buttons. At most only one button variable is set, which usually is the first button in the HTML, but you have no way to change which will be set. If you use an hidden field is easier to determine whether the form was submitted or not, as you do not have to check variables for all buttons. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
Hello, on 10/02/2009 07:11 AM kranthi said the following: You say you don't use hidden fields because they can be modified too easily, yet you say you check for the submit button? Which out of the two do you do, as last time I checked, modifying one form field is as easy as changing any other! I completely agree with you. changing submit text is as easy as changing hidden fields, but its less likely for a user to modify a submit button as compared to a hidden field. moreover it just reduces my typing load. (This is just my practice) How come an user can modify a hidden field is more likely to change submit button? I don't think an average user will modify anything at all. Also worth noting, you can only successfully check for the name=submit value if there is only one submit button in your form, as that is then the default (and only) submit that the form can use, so it uses that. If you have more than one submit button (and this includes image input elements) then using the keyboard will use the first submit field it finds I believe. Cant agree with you on this though. as far as i know using name= (names of the two buttons may/may not be unique) is the only way to track form submission for forms with multiple submit buttons. Please point out if you think otherwise As everbody has been telling you, if you check an hidden field it will work regardless whether the user clicked on a button or hit enter on a text input. With multiple buttons there is no way (except for using some Javascript) to tell whether it was clicked a button or the user hit enter in a text input. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? Ps- I've googled: php redirect success page on self submit form and similar... Regards, Márcio -Original Message- From: Bob McConnell [mailto:r...@cbord.com] Sent: sexta-feira, 24 de Abril de 2009 14:10 To: PHP-General List Subject: RE: [PHP] Self-Process php forms or not? When you have it all in one file, the first thing you do is check to see if this request was submitted from the form. If not, you send the blank form. If it was, you validate all of the data. When a validation fails, you add error messages and resend the form with any fields that passed the validation already filled in. When validation succeeds, process and move on. No muss, no fuss. Bob McConnell -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: Friday, April 24, 2009 8:53 AM To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa - Original Message - From: MEM tal...@gmail.com To: 'PHP-General List' php-general@lists.php.net Sent: Friday, April 24, 2009 2:34 PM Subject: [PHP] Self-Process php forms or not? I'm trying to understand the advantages behind opting by using a Self-Process PHP Form, instead of having a form and then point the action of the form to another .php page. Can anyone point me some resources about this. Why using one instead of another. What are the main advantages? Regards, Márcio -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
May be it is best time to for you to start using Zend Framework - Zend_Form -Original Message- From: MEM [mailto:tal...@gmail.com] Sent: Thursday, October 01, 2009 3:01 PM To: 'Bob McConnell'; 'PHP-General List' Subject: RE: [PHP] Self-Process php forms or not? One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? Ps- I've googled: php redirect success page on self submit form and similar... Regards, Márcio -Original Message- From: Bob McConnell [mailto:r...@cbord.com] Sent: sexta-feira, 24 de Abril de 2009 14:10 To: PHP-General List Subject: RE: [PHP] Self-Process php forms or not? When you have it all in one file, the first thing you do is check to see if this request was submitted from the form. If not, you send the blank form. If it was, you validate all of the data. When a validation fails, you add error messages and resend the form with any fields that passed the validation already filled in. When validation succeeds, process and move on. No muss, no fuss. Bob McConnell -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: Friday, April 24, 2009 8:53 AM To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa - Original Message - From: MEM tal...@gmail.com To: 'PHP-General List' php-general@lists.php.net Sent: Friday, April 24, 2009 2:34 PM Subject: [PHP] Self-Process php forms or not? I'm trying to understand the advantages behind opting by using a Self-Process PHP Form, instead of having a form and then point the action of the form to another .php page. Can anyone point me some resources about this. Why using one instead of another. What are the main advantages? Regards, Márcio -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On 10/1/09 8:00 AM, MEM tal...@gmail.com wrote: One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? i use one php script that knows how to deliver more than one html page depending on the outcome of processing of form input and the rest. i'm sure there are other ways. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
I've used the form page with a the following code (at the bottom - but before any output is done) to redirect to a thank you page: if ($submittedcorrectly) { header(Location: thankyou.htm); exit(); } HTH J -Original Message- From: MEM [mailto:tal...@gmail.com] Sent: 01 October 2009 13:01 To: 'Bob McConnell'; 'PHP-General List' Subject: RE: [PHP] Self-Process php forms or not? One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? Ps- I've googled: php redirect success page on self submit form and similar... Regards, Márcio -Original Message- From: Bob McConnell [mailto:r...@cbord.com] Sent: sexta-feira, 24 de Abril de 2009 14:10 To: PHP-General List Subject: RE: [PHP] Self-Process php forms or not? When you have it all in one file, the first thing you do is check to see if this request was submitted from the form. If not, you send the blank form. If it was, you validate all of the data. When a validation fails, you add error messages and resend the form with any fields that passed the validation already filled in. When validation succeeds, process and move on. No muss, no fuss. Bob McConnell -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: Friday, April 24, 2009 8:53 AM To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa - Original Message - From: MEM tal...@gmail.com To: 'PHP-General List' php-general@lists.php.net Sent: Friday, April 24, 2009 2:34 PM Subject: [PHP] Self-Process php forms or not? I'm trying to understand the advantages behind opting by using a Self-Process PHP Form, instead of having a form and then point the action of the form to another .php page. Can anyone point me some resources about this. Why using one instead of another. What are the main advantages? Regards, Márcio -- 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 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] Self-Process php forms or not?
Original Message From: Mert Oztekin mozte...@anadolusigorta.com.tr To: MEM tal...@gmail.com; Bob McConnell r...@cbord.com; PHP-General List php-general@lists.php.net Sent: Thursday, October 1, 2009 5:16:40 AM Subject: RE: [PHP] Self-Process php forms or not? May be it is best time to for you to start using Zend Framework - Zend_Form -Original Message- From: MEM [mailto:tal...@gmail.com] Sent: Thursday, October 01, 2009 3:01 PM To: 'Bob McConnell'; 'PHP-General List' Subject: RE: [PHP] Self-Process php forms or not? One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? Use of javascript to validate form is not required but will help with (processing) load on the server side. However, you should always validate and sanitize all user input on server side if you want to maintain good data integrity in your DB and security. Why? In case someone uses cURL or another TCP app to do GET/POST to your app (server) ;) As for redirecting w/o javascript, it's easy. Here's a sample: entryForm.php post to $self or other $url $self / $url validates the form * if valid form redirect via header() or include/require another modular page (suggested) * else invalid form show entryForm.php with errors You can either pass the variables via GET in your redirect or use $_SESSION variables. I prefer $_SESSION since you really make your app modular and have access to those variables from any include/require page. If you're really innovative, you could expand on it to have more performance ;) Regards, Tommy Ps- I've googled: php redirect success page on self submit form and similar... Regards, Márcio -Original Message- From: Bob McConnell [mailto:r...@cbord.com] Sent: sexta-feira, 24 de Abril de 2009 14:10 To: PHP-General List Subject: RE: [PHP] Self-Process php forms or not? When you have it all in one file, the first thing you do is check to see if this request was submitted from the form. If not, you send the blank form. If it was, you validate all of the data. When a validation fails, you add error messages and resend the form with any fields that passed the validation already filled in. When validation succeeds, process and move on. No muss, no fuss. Bob McConnell -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: Friday, April 24, 2009 8:53 AM To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa - Original Message - From: MEM To: 'PHP-General List' Sent: Friday, April 24, 2009 2:34 PM Subject: [PHP] Self-Process php forms or not? I'm trying to understand the advantages behind opting by using a Self-Process PHP Form, instead of having a form and then point the action of the form to another .php page. Can anyone point me some resources about this. Why using one instead of another. What are the main advantages? Regards, Márcio -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system. -- PHP General Mailing List (http://www.php.net/) To unsubscribe
RE: [PHP] Self-Process php forms or not?
At 1:00 PM +0100 10/1/09, MEM wrote: One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? MEM: Here's what I do -- it's pretty simple. I use a hidden input variable I call step and monitor it as the user clicks whatever form submit they are on -- it works like so: $step = isset($_POST['step']) ? $_POST['step'] : 0; switch ($step) { case 0: // present the first form to the user // collect data // you can enhance the user experience by using javascript here. // input type=hidden name=step value=1 break; case 1: // present second form to the user // clean data // if data OK then record data in db input type=hidden name=step value=2 // if data not OK then send user back input type=hidden name=step value=0 break; case 2: //present the third form to the user // success, or confirmation, or thank you page break; } Now, to make things easier for the user, be sure to set session variables for all the data collected in the first form so that IF you send the user back to the first form, the user doesn't have to reenter everything. HTH, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On Thu, 2009-10-01 at 09:30 -0400, Tom Worster wrote: On 10/1/09 8:00 AM, MEM tal...@gmail.com wrote: One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? i use one php script that knows how to deliver more than one html page depending on the outcome of processing of form input and the rest. i'm sure there are other ways. The way I always tend to do something like this is as follows: $errors = false; if(isset($_REQUEST['submit'])) { // process form here // if it doesn't validate $errors to true // you can either redirect here, or display the confirmation message } if(!isset($_REQUEST['submit']) || $errors) { // display form // if $errors is true populate the form with user submitted data } Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
On 10/1/09 10:13 AM, tedd tedd.sperl...@gmail.com wrote: At 1:00 PM +0100 10/1/09, MEM wrote: One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? MEM: Here's what I do -- it's pretty simple. I use a hidden input variable I call step and monitor it as the user clicks whatever form submit they are on -- it works like so: $step = isset($_POST['step']) ? $_POST['step'] : 0; switch ($step) { case 0: // present the first form to the user // collect data // you can enhance the user experience by using javascript here. // input type=hidden name=step value=1 break; case 1: // present second form to the user // clean data // if data OK then record data in db input type=hidden name=step value=2 // if data not OK then send user back input type=hidden name=step value=0 break; case 2: //present the third form to the user // success, or confirmation, or thank you page break; } Now, to make things easier for the user, be sure to set session variables for all the data collected in the first form so that IF you send the user back to the first form, the user doesn't have to reenter everything. i do pretty much the same thing. each form in my html template files has a form name tucked away in a hidden input element. the only difference from your method is that the names are unique across the application. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
Thanks a lot to all, I will see what best fits my limited knowledge, and choose the possible option. Regards, Márcio -Original Message- From: Tom Worster [mailto:f...@thefsb.org] Sent: quinta-feira, 1 de Outubro de 2009 20:11 To: tedd; 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? On 10/1/09 10:13 AM, tedd tedd.sperl...@gmail.com wrote: At 1:00 PM +0100 10/1/09, MEM wrote: One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? MEM: Here's what I do -- it's pretty simple. I use a hidden input variable I call step and monitor it as the user clicks whatever form submit they are on -- it works like so: $step = isset($_POST['step']) ? $_POST['step'] : 0; switch ($step) { case 0: // present the first form to the user // collect data // you can enhance the user experience by using javascript here. // input type=hidden name=step value=1 break; case 1: // present second form to the user // clean data // if data OK then record data in db input type=hidden name=step value=2 // if data not OK then send user back input type=hidden name=step value=0 break; case 2: //present the third form to the user // success, or confirmation, or thank you page break; } Now, to make things easier for the user, be sure to set session variables for all the data collected in the first form so that IF you send the user back to the first form, the user doesn't have to reenter everything. i do pretty much the same thing. each form in my html template files has a form name tucked away in a hidden input element. the only difference from your method is that the names are unique across the application. -- 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] Self-Process php forms or not?
Hello, on 10/01/2009 09:00 AM MEM said the following: One last question about this: I've done a self submit form, after hearing all the advantages expressed here. But how could we relate, without using javascript, a self submit form with a success page or a confirmation page that doesn't show the form? Can please someone throw me some infos about this please? Ps- I've googled: php redirect success page on self submit form and similar... All you need to do is to include an hidden field in the form. Then check the respective $_POST or $_GET variable is set. If it is not set, show the form for the first time. If it is set, validate the form and process it. If the form is not valid, show the form again with previously submitted values. This tutorial video explains this workflow: http://www.phpclasses.org/browse/video/1/package/1/section/usage.html This example script demonstrates how to setup your code. It uses a function of a forms class name WasSubmiteed() to check if the form is being presented for the first time or is being submitted: http://www.meta-language.net/forms-examples.html?example=test_formcode=1 -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa - Original Message - From: MEM tal...@gmail.com To: 'PHP-General List' php-general@lists.php.net Sent: Friday, April 24, 2009 2:34 PM Subject: [PHP] Self-Process php forms or not? I'm trying to understand the advantages behind opting by using a Self-Process PHP Form, instead of having a form and then point the action of the form to another .php page. Can anyone point me some resources about this. Why using one instead of another. What are the main advantages? Regards, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
So, on your opinion, we can call that method, on some circumstances, a good practice? What about the moto: let's separate business from presentation? Thanks once again, Márcio -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: sexta-feira, 24 de Abril de 2009 13:53 To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
When you have it all in one file, the first thing you do is check to see if this request was submitted from the form. If not, you send the blank form. If it was, you validate all of the data. When a validation fails, you add error messages and resend the form with any fields that passed the validation already filled in. When validation succeeds, process and move on. No muss, no fuss. Bob McConnell -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: Friday, April 24, 2009 8:53 AM To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa - Original Message - From: MEM tal...@gmail.com To: 'PHP-General List' php-general@lists.php.net Sent: Friday, April 24, 2009 2:34 PM Subject: [PHP] Self-Process php forms or not? I'm trying to understand the advantages behind opting by using a Self-Process PHP Form, instead of having a form and then point the action of the form to another .php page. Can anyone point me some resources about this. Why using one instead of another. What are the main advantages? Regards, Márcio -- 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] Self-Process php forms or not?
[snip] What about the moto: let's separate business from presentation?[/snip] This depends on how strictly you're following any given model like MVC. IMHO you should use the right tool for the job. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Self-Process php forms or not?
Well, if you keen on separating business from presentation (which is usually a good practice), you can always do this: ?php if (isset($_POST['action'])) { if (DoProcess($_POST)) { PrintSuccess(); } else { PrintFailure(); PrintForm(); } } ? So you can call in fact the processing page, the real presentation can be in another PHP file, as well as the processing functions. Of course, instead of PrintForm() you can actually implant the real HTML code. And by the way, if you keep the form and the processing parts in one file, and create the form like this: FORM action=?= $_SERVER['PHP_SELF'] ? you can name your file as you want, it will work without rewriting the page. SanTa - Original Message - From: MEM tal...@gmail.com To: 'Sándor Tamás (HostWare Kft.)' sandorta...@hostware.hu; 'PHP-General List' php-general@lists.php.net Sent: Friday, April 24, 2009 3:03 PM Subject: RE: [PHP] Self-Process php forms or not? So, on your opinion, we can call that method, on some circumstances, a good practice? What about the moto: let's separate business from presentation? Thanks once again, Márcio -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: sexta-feira, 24 de Abril de 2009 13:53 To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa -- 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] Self-Process php forms or not?
Having a script that is self executing - when it posts back to itself instead of a separate script - has absolutely nothing to do with the separation of business and presentation. It is possible for a single script to use separate components for the presentation, business and data access layers. -- Tony Marston http://www.tonymarston.net http://www.radicore.org MEM tal...@gmail.com wrote in message news:002b01c9c4dd$08569bc0$1903d3...@com... So, on your opinion, we can call that method, on some circumstances, a good practice? What about the moto: let's separate business from presentation? Thanks once again, Márcio -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: sexta-feira, 24 de Abril de 2009 13:53 To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Self-Process php forms or not?
Thanks to all for your replies. I'm more elucidated about the possibilities now. I have seen here a lot of keywords to start digging. :) Thanks once again, Márcio -Original Message- From: Tony Marston [mailto:t...@marston-home.demon.co.uk] Sent: sexta-feira, 24 de Abril de 2009 14:20 To: php-general@lists.php.net Subject: Re: [PHP] Self-Process php forms or not? Having a script that is self executing - when it posts back to itself instead of a separate script - has absolutely nothing to do with the separation of business and presentation. It is possible for a single script to use separate components for the presentation, business and data access layers. -- Tony Marston http://www.tonymarston.net http://www.radicore.org MEM tal...@gmail.com wrote in message news:002b01c9c4dd$08569bc0$1903d3...@com... So, on your opinion, we can call that method, on some circumstances, a good practice? What about the moto: let's separate business from presentation? Thanks once again, Márcio -Original Message- From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu] Sent: sexta-feira, 24 de Abril de 2009 13:53 To: 'PHP-General List' Subject: Re: [PHP] Self-Process php forms or not? I think the main advantage is that if something goes wrong processing the datas, you can show the form again without redirecting again. And if you have to change the behavior of the page, you have to change only one file instead of two. SanTa -- 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