Re: [PHP] {} forms
On 16 November 2011 13:56, Tim Streater t...@clothears.org.uk wrote: I'm looking at the source of a web sockets server and I see these various forms: ws://{$host}{$path} HTTP/1.1 ${status}\r\n Are these simply equivalent to: ws:// . $host . $path HTTP/1.1 . $status . \r\n; and if so, is there any particular benefit to using that form? Or if not, what do they mean? (I've read up about variable variables). Thanks, -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you want to embed $array[CONSTANT], then the {} is used. I use {} out of habit for non arrays. Not sure if there is an impact. http://docs.php.net/manual/en/language.types.string.php#example-71 shows the use. Oh. I've fixed the layout bug for http://docs.php.net/manual/en/language.types.string.php#example-70. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] {} forms
On 16 Nov 2011 at 14:27, Richard Quadling rquadl...@gmail.com wrote: If you want to embed $array[CONSTANT], then the {} is used. I use {} out of habit for non arrays. Not sure if there is an impact. http://docs.php.net/manual/en/language.types.string.php#example-71 shows the use. Oh. I've fixed the layout bug for http://docs.php.net/manual/en/language.types.string.php#example-70. Ah *that's* where it was hiding. Thanks - got it now. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] {} forms
On 11-11-16 09:27 AM, Richard Quadling wrote: On 16 November 2011 13:56, Tim Streatert...@clothears.org.uk wrote: I'm looking at the source of a web sockets server and I see these various forms: ws://{$host}{$path} HTTP/1.1 ${status}\r\n Are these simply equivalent to: ws:// . $host . $path HTTP/1.1 . $status . \r\n; and if so, is there any particular benefit to using that form? Or if not, what do they mean? (I've read up about variable variables). If you want to embed $array[CONSTANT], then the {} is used. I use {} out of habit for non arrays. Not sure if there is an impact. The braces are also used when the characters following the variable are also valid variable name characters :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
Andrew Ballard wrote: On Wed, Jun 3, 2009 at 7:13 PM, PJ af.gour...@videotron.ca wrote: Tom Chubb wrote: 2009/6/3 PJ af.gour...@videotron.ca: The code: ...snip div id=loginbox     form name=login method=post action=? echo $_SERVER['PHP_SELF'] ?       h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br /       mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br /       input class=submit name=submit type=submit value=    entrez   /br //h2       h2a href=inscription.php Inscription /a/h2     /form   /div snip... PROBLEM 1: On Firefox3, the first input (accès client) does not accept any input, does not show the cursor; the second input (mot de passe) works fine. PROBLEM 2: The form does not appear on IE 6 Running FreeBSD 7.1, apache22, php 5, using sessions, CSS Am I doing something wrong? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com  http://www.ptahhotep.com  http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think the first problem is because both your inputs are defined as title. Does that change anything in the functionanlity? If so, how? Bastien says it works in IE8; here it does not in IE6. :-) I'm not sure about functionanlity, but it definitely changes the functionality. ;-) It means that regardless of whether someone is able to enter a value in the field you have labeled accès client, your PHP page will never see it because it will look at the value from the field you have labeled mot de passe, even if it is left blank. And that is true regardless of which browser they are using. In some scripting platform other than PHP, or if you process the raw post data yourself it could be different, but in PHP the variable $_POST['title'] will only have one value in it, and it will be the last one passed by the form. (In this case, mot de passe.) Andrew Thanks Andrew, I hadn't gotten that far and had not thought about that... it's a wake-up call for me. Glad to learn that. PJ -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
Shawn McKenzie wrote: PJ wrote: AngeloZanetti wrote: Shawn McKenzie wrote: PJ wrote: PROBLEM 1 solved: errant divs removed; strange that they were inhibiting entry of data into form field? PROBLEM 2 not resolved: but the form was off the page and clipped in upper right hand corner. What can be done to get it to show correctly? Remove the link to any stylesheets that you're using and see what it looks like. Where is your source code / form so we can see what is going on? http://www.Elemental.co.za http://www.Elemental.co.za http://www.wapit.co.za http://www.wapit.co.za The code: ...snip div id=loginbox form name=login method=post action=? echo $_SERVER['PHP_SELF'] ? h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br / mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br / input class=submit name=submit type=submit value= entrez /br //h2 h2a href=inscription.php Inscription /a/h2 /form /div snip... I had posted this earlier... just before finding the blockage for the input in PROBLEM 1, though I don't know why some stray divs would cause that. Based on the fact that you said things were off the page and clipped in the upper right hand corner, I thought that you had a style that may have positioned the div or the form or something. If you disable all styles, whether in the head of the document or via an external stylesheet, then that should show the form on the page as it should. I think I didn't explain correctly; It does not appear on the page(IE 6) as it should does in Firefox3. The form is displayed but off-screen on startup; The page is set for a width of 1025px but the display is probably about 900px so the form is just off-screen to the right. But it is clipped in the middle and all you see is the password and submit fields. I suspect that the guilty party here is the CSS - I have the top margin set to -100px in order to position it where I want it. I guess, I have to find another way to position it. :-( -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
On Wed, Jun 3, 2009 at 11:55 AM, PJ af.gour...@videotron.ca wrote: The code: ...snip div id=loginbox form name=login method=post action=? echo $_SERVER['PHP_SELF'] ? h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br / mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br / input class=submit name=submit type=submit value= entrez /br //h2 h2a href=inscription.php Inscription /a/h2 /form /div snip... PROBLEM 1: On Firefox3, the first input (accès client) does not accept any input, does not show the cursor; the second input (mot de passe) works fine. PROBLEM 2: The form does not appear on IE 6 Running FreeBSD 7.1, apache22, php 5, using sessions, CSS Am I doing something wrong? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php works in IE8 and Chorme Doesn't look like anything is wrong..post more code -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
2009/6/3 PJ af.gour...@videotron.ca: The code: ...snip div id=loginbox form name=login method=post action=? echo $_SERVER['PHP_SELF'] ? h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br / mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br / input class=submit name=submit type=submit value= entrez /br //h2 h2a href=inscription.php Inscription /a/h2 /form /div snip... PROBLEM 1: On Firefox3, the first input (accès client) does not accept any input, does not show the cursor; the second input (mot de passe) works fine. PROBLEM 2: The form does not appear on IE 6 Running FreeBSD 7.1, apache22, php 5, using sessions, CSS Am I doing something wrong? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think the first problem is because both your inputs are defined as title. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
Tom Chubb wrote: 2009/6/3 PJ af.gour...@videotron.ca: The code: ...snip div id=loginbox form name=login method=post action=? echo $_SERVER['PHP_SELF'] ? h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br / mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br / input class=submit name=submit type=submit value= entrez /br //h2 h2a href=inscription.php Inscription /a/h2 /form /div snip... PROBLEM 1: On Firefox3, the first input (accès client) does not accept any input, does not show the cursor; the second input (mot de passe) works fine. PROBLEM 2: The form does not appear on IE 6 Running FreeBSD 7.1, apache22, php 5, using sessions, CSS Am I doing something wrong? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think the first problem is because both your inputs are defined as title. Does that change anything in the functionanlity? If so, how? Bastien says it works in IE8; here it does not in IE6. :-) -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
AngeloZanetti wrote: Shawn McKenzie wrote: PJ wrote: PROBLEM 1 solved: errant divs removed; strange that they were inhibiting entry of data into form field? PROBLEM 2 not resolved: but the form was off the page and clipped in upper right hand corner. What can be done to get it to show correctly? Remove the link to any stylesheets that you're using and see what it looks like. Where is your source code / form so we can see what is going on? http://www.Elemental.co.za http://www.Elemental.co.za http://www.wapit.co.za http://www.wapit.co.za The code: ...snip div id=loginbox form name=login method=post action=? echo $_SERVER['PHP_SELF'] ? h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br / mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br / input class=submit name=submit type=submit value= entrez /br //h2 h2a href=inscription.php Inscription /a/h2 /form /div snip... I had posted this earlier... just before finding the blockage for the input in PROBLEM 1, though I don't know why some stray divs would cause that. -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
PJ wrote: AngeloZanetti wrote: Shawn McKenzie wrote: PJ wrote: PROBLEM 1 solved: errant divs removed; strange that they were inhibiting entry of data into form field? PROBLEM 2 not resolved: but the form was off the page and clipped in upper right hand corner. What can be done to get it to show correctly? Remove the link to any stylesheets that you're using and see what it looks like. Where is your source code / form so we can see what is going on? http://www.Elemental.co.za http://www.Elemental.co.za http://www.wapit.co.za http://www.wapit.co.za The code: ...snip div id=loginbox form name=login method=post action=? echo $_SERVER['PHP_SELF'] ? h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br / mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br / input class=submit name=submit type=submit value= entrez /br //h2 h2a href=inscription.php Inscription /a/h2 /form /div snip... I had posted this earlier... just before finding the blockage for the input in PROBLEM 1, though I don't know why some stray divs would cause that. Based on the fact that you said things were off the page and clipped in the upper right hand corner, I thought that you had a style that may have positioned the div or the form or something. If you disable all styles, whether in the head of the document or via an external stylesheet, then that should show the form on the page as it should. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms problem
On Wed, Jun 3, 2009 at 7:13 PM, PJ af.gour...@videotron.ca wrote: Tom Chubb wrote: 2009/6/3 PJ af.gour...@videotron.ca: The code: ...snip div id=loginbox form name=login method=post action=? echo $_SERVER['PHP_SELF'] ? h2accegrave;s client br /input type=text name=title value=? echo $user; ? size=10 /br / mot de passe br /input type=text name=title value=? echo $passwd; ? size=10 /br / input class=submit name=submit type=submit value= entrez /br //h2 h2a href=inscription.php Inscription /a/h2 /form /div snip... PROBLEM 1: On Firefox3, the first input (accès client) does not accept any input, does not show the cursor; the second input (mot de passe) works fine. PROBLEM 2: The form does not appear on IE 6 Running FreeBSD 7.1, apache22, php 5, using sessions, CSS Am I doing something wrong? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think the first problem is because both your inputs are defined as title. Does that change anything in the functionanlity? If so, how? Bastien says it works in IE8; here it does not in IE6. :-) I'm not sure about functionanlity, but it definitely changes the functionality. ;-) It means that regardless of whether someone is able to enter a value in the field you have labeled accès client, your PHP page will never see it because it will look at the value from the field you have labeled mot de passe, even if it is left blank. And that is true regardless of which browser they are using. In some scripting platform other than PHP, or if you process the raw post data yourself it could be different, but in PHP the variable $_POST['title'] will only have one value in it, and it will be the last one passed by the form. (In this case, mot de passe.) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms validation and creation- easier solution?
Hello, on 05/20/2009 11:09 AM Paul M Foster said the following: Both this class and Manuel Lemos' form generation class (from phpclasses.org) will create beautiful forms for you. However, you may find that the amount of [repetitive] typing you do will be equivalent or greater than simply creating the form by hand. The best solution would probably be a form you fill out which asks you about all the fields you want, and then generates the code to paint the form. There are commercial solutions which do this, and some (not that great) free solutions. I'm working on one myself, which will eventually be a sourceforge/freshmeat project. Thank you for mentioning my package, but I am not sure what you mean. The Forms Generation and Validation package seems to do exactly what you describe and more. IMHO, creating forms by hand is by no means simpler, especially if you want to include browser side (Javascript) validation. I mean, I am not masochist to create something that will give me more work in the end to develop PHP forms based applications than if I would type HTML manually. Furthermore, the plug-ins that come with the package dramatically reduce the amount of code you need to type to achieve the same generating common HTML inputs manually. Anyone can judge by yourself by going here and see several example forms and the actual code that it takes to generate them: http://www.meta-language.net/forms-examples.html For instance this scaffolding plug-in generates CRUD forms that you often need to manage data stored for instance in databases. http://www.meta-language.net/forms-examples.html?example=test_scaffolding_input For those interested to check it out, the actual class package can be downloaded from here: http://www.phpclasses.org/formsgeneration Here you may watch an extensive tutorial video that covers practically all features: http://www.phpclasses.org/browse/video/1/package/1.html -- 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] Forms validation and creation- easier solution?
-Original Message- From: Manuel Lemos [mailto:mle...@acm.org] Sent: 22 May 2009 09:56 To: Paul M Foster Cc: php-general@lists.php.net; Angelo Zanetti Subject: Re: [PHP] Forms validation and creation- easier solution? Hello, on 05/20/2009 11:09 AM Paul M Foster said the following: Both this class and Manuel Lemos' form generation class (from phpclasses.org) will create beautiful forms for you. However, you may find that the amount of [repetitive] typing you do will be equivalent or greater than simply creating the form by hand. The best solution would probably be a form you fill out which asks you about all the fields you want, and then generates the code to paint the form. There are commercial solutions which do this, and some (not that great) free solutions. I'm working on one myself, which will eventually be a sourceforge/freshmeat project. Thank you for mentioning my package, but I am not sure what you mean. The Forms Generation and Validation package seems to do exactly what you describe and more. IMHO, creating forms by hand is by no means simpler, especially if you want to include browser side (Javascript) validation. I mean, I am not masochist to create something that will give me more work in the end to develop PHP forms based applications than if I would type HTML manually. Furthermore, the plug-ins that come with the package dramatically reduce the amount of code you need to type to achieve the same generating common HTML inputs manually. Anyone can judge by yourself by going here and see several example forms and the actual code that it takes to generate them: http://www.meta-language.net/forms-examples.html For instance this scaffolding plug-in generates CRUD forms that you often need to manage data stored for instance in databases. http://www.meta-language.net/forms-examples.html?example=test_scaffolding_in put For those interested to check it out, the actual class package can be downloaded from here: http://www.phpclasses.org/formsgeneration Here you may watch an extensive tutorial video that covers practically all features: http://www.phpclasses.org/browse/video/1/package/1.html Thanks manuel. I will check out the class. Much appreciated your response. Thanks Angelo Elemental http://www.elemental.co.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms validation and creation- easier solution?
On Fri, May 22, 2009 at 04:56:01AM -0300, Manuel Lemos wrote: Hello, on 05/20/2009 11:09 AM Paul M Foster said the following: Both this class and Manuel Lemos' form generation class (from phpclasses.org) will create beautiful forms for you. However, you may find that the amount of [repetitive] typing you do will be equivalent or greater than simply creating the form by hand. The best solution would probably be a form you fill out which asks you about all the fields you want, and then generates the code to paint the form. There are commercial solutions which do this, and some (not that great) free solutions. I'm working on one myself, which will eventually be a sourceforge/freshmeat project. Thank you for mentioning my package, but I am not sure what you mean. The Forms Generation and Validation package seems to do exactly what you describe and more. IMHO, creating forms by hand is by no means simpler, especially if you want to include browser side (Javascript) validation. I mean, I am not masochist to create something that will give me more work in the end to develop PHP forms based applications than if I would type HTML manually. Furthermore, the plug-ins that come with the package dramatically reduce the amount of code you need to type to achieve the same generating common HTML inputs manually. Anyone can judge by yourself by going here and see several example forms and the actual code that it takes to generate them: http://www.meta-language.net/forms-examples.html For instance this scaffolding plug-in generates CRUD forms that you often need to manage data stored for instance in databases. http://www.meta-language.net/forms-examples.html?example=test_scaffolding_input For those interested to check it out, the actual class package can be downloaded from here: http://www.phpclasses.org/formsgeneration Here you may watch an extensive tutorial video that covers practically all features: http://www.phpclasses.org/browse/video/1/package/1.html Here's what I was talking about. Assuming you simply type out your form fields like this: input type=text name=address size=30 value=123 Main St./ Now, if you do it with a class like yours: $arr = array('type' = 'text', 'name' = 'address', 'size' = 30, 'value' = '123 Main St.'); $form-AddInput($arr); (I haven't looked at your class in a while, so I may have invoked it slightly incorrectly.) If you compare the typing involved in the first case with the typing involved in the second case, you can see that it's more in the second case. Yes, your forms generation class includes a tremendous amount of proven code, including a bunch of Javascript validation, all of which the programmer doesn't have to develop himself. The only real complaint I have about your class is that the class file itself (forms.php) is 158+ K bytes, which must be loaded every time you surf to a page for the first time. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms validation and creation- easier solution?
Viva, on 05/22/2009 10:36 AM Paul M Foster said the following: IMHO, creating forms by hand is by no means simpler, especially if you want to include browser side (Javascript) validation. I mean, I am not masochist to create something that will give me more work in the end to develop PHP forms based applications than if I would type HTML manually. Furthermore, the plug-ins that come with the package dramatically reduce the amount of code you need to type to achieve the same generating common HTML inputs manually. Anyone can judge by yourself by going here and see several example forms and the actual code that it takes to generate them: http://www.meta-language.net/forms-examples.html For instance this scaffolding plug-in generates CRUD forms that you often need to manage data stored for instance in databases. http://www.meta-language.net/forms-examples.html?example=test_scaffolding_input For those interested to check it out, the actual class package can be downloaded from here: http://www.phpclasses.org/formsgeneration Here you may watch an extensive tutorial video that covers practically all features: http://www.phpclasses.org/browse/video/1/package/1.html Here's what I was talking about. Assuming you simply type out your form fields like this: input type=text name=address size=30 value=123 Main St./ Now, if you do it with a class like yours: $arr = array('type' = 'text', 'name' = 'address', 'size' = 30, 'value' = '123 Main St.'); $form-AddInput($arr); (I haven't looked at your class in a while, so I may have invoked it slightly incorrectly.) If you compare the typing involved in the first case with the typing involved in the second case, you can see that it's more in the second case. That is because you are just thinking about the typing of the generated HTML. To generate and validate forms, you also have to consider the code you write to validate and process the forms because the HTML forms do not process by themselves. You need to think about the security of your application, so you also need to validate submitted values, discard invalid values, escape outputted values, and so on. All that is done with a couple of calls to the forms class. Yes, your forms generation class includes a tremendous amount of proven code, including a bunch of Javascript validation, all of which the programmer doesn't have to develop himself. The only real complaint I have about your class is that the class file itself (forms.php) is 158+ K bytes, which must be loaded every time you surf to a page for the first time. That used to be an issue in the 20th century in the PHP 3 days. Since PHP 4, the PHP code is no longer interpreted. The Zend engine compiles the PHP code in Zend op codes in the first stage. In the second stage the op codes are executed. If you use a cache extension like APC, Turck MMCache, XCache, etc.. the first step is skipped after the first execution and the size of the original code is not relevant because it is already compiled in shared memory. Anyway, the class has all that code because it is necessary to implement all it supports. -- 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] Forms validation and creation- easier solution?
On May 20, 2009, at 2:03 AM, Angelo Zanetti wrote: We have done quite a few projects and we are looking to find better ways to implementing forms. This is fairly simple to roll-your-own. I do it from metadata. I check MySQL metadata for data types, lengths, and defaults. In addition, my metadata tables contain: -- field captions -- field-use descriptions and business rules (generates CSS pop-up help) -- the type of control used -- the source of data for controls (I call system codes: like the lists of choices for comboboxes and radio buttons -- I keep almost all of these in a single table.) -- whether data in a field is required -- whether the data in a field are visible, editable, or new-record- only editable -- whether the data are encrypted (core data class handles the encryption/decryption) -- data entry order -- any non-standard user rights to the data. -- Simple business rules (like maximums, minimums and ranges of acceptable values) -- easy validation categories: birthdates, eMail formatting, USA phone numbers postal codes, US social security #'s, credit card format, and the like. The last two can generate JavaScript, too (still working on that). -- I also am working on more complex validation being automatic: across fields or tables, dependent on other variables, etc. By standardizing the format of metadata and the means of storing system code values, plus core CSS class names, you can use this across projects. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms validation and creation- easier solution?
Hi! Zend framework has a wonderful solution to solve this task. You can download even the demo showing how to do this task Best regards, Alex. 2009/5/20 Angelo Zanetti ang...@zlogic.co.za Hi all. We have done quite a few projects and we are looking to find better ways to implementing forms. Forms seem to be quite time consuming and repetitive. Generally are there any classes or libraries that will assist with: 1. Easy creation of forms (fields and layout) 2. Validation of specific fields within the forms (server side not JS) 3. Decrease in time required to setup the forms pages any other comments are welcome. Thanks in advance Angelo Elemental http://www.elemental.co.za http://www.elemental.co.za/ Dynamic Web and Mobile Solutions
RE: [PHP] Forms validation and creation- easier solution?
_ From: Olexandr Heneralov [mailto:ohenera...@gmail.com] Sent: 20 May 2009 09:08 To: Angelo Zanetti Cc: php-general@lists.php.net Subject: Re: [PHP] Forms validation and creation- easier solution? Hi! Zend framework has a wonderful solution to solve this task. You can download even the demo showing how to do this task Best regards, Alex. Thanks Alex. But would that mean that I need to implement the entire Framework or can I just use the class to incorporate into our new projects (bespoke applications - custom developed). Looking forward to your reply! Angelo 2009/5/20 Angelo Zanetti ang...@zlogic.co.za Hi all. We have done quite a few projects and we are looking to find better ways to implementing forms. Forms seem to be quite time consuming and repetitive. Generally are there any classes or libraries that will assist with: 1. Easy creation of forms (fields and layout) 2. Validation of specific fields within the forms (server side not JS) 3. Decrease in time required to setup the forms pages any other comments are welcome. Thanks in advance Angelo Elemental http://www.elemental.co.za http://www.elemental.co.za/ Dynamic Web and Mobile Solutions
Re: [PHP] Forms validation and creation- easier solution?
Hi! No, you should not use all the framework. You can use just a class - Zend_Form ( http://framework.zend.com/manual/en/zend.form.quickstart.html). 2009/5/20 Angelo Zanetti ang...@zlogic.co.za -- *From:* Olexandr Heneralov [mailto:ohenera...@gmail.com] *Sent:* 20 May 2009 09:08 *To:* Angelo Zanetti *Cc:* php-general@lists.php.net *Subject:* Re: [PHP] Forms validation and creation- easier solution? Hi! Zend framework has a wonderful solution to solve this task. You can download even the demo showing how to do this task Best regards, Alex. Thanks Alex. But would that mean that I need to implement the entire Framework or can I just use the class to incorporate into our new projects (bespoke applications – custom developed). Looking forward to your reply! Angelo 2009/5/20 Angelo Zanetti ang...@zlogic.co.za Hi all. We have done quite a few projects and we are looking to find better ways to implementing forms. Forms seem to be quite time consuming and repetitive. Generally are there any classes or libraries that will assist with: 1. Easy creation of forms (fields and layout) 2. Validation of specific fields within the forms (server side not JS) 3. Decrease in time required to setup the forms pages any other comments are welcome. Thanks in advance Angelo Elemental http://www.elemental.co.za http://www.elemental.co.za/ Dynamic Web and Mobile Solutions
RE: [PHP] Forms validation and creation- easier solution?
[snip] 1. Easy creation of forms (fields and layout) [/snip] I posted a form function several months ago that will help you with this. Just search the list archives -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms validation and creation- easier solution?
On Wed, May 20, 2009 at 10:08:12AM +0300, Olexandr Heneralov wrote: 2009/5/20 Angelo Zanetti ang...@zlogic.co.za Hi all. We have done quite a few projects and we are looking to find better ways to implementing forms. Forms seem to be quite time consuming and repetitive. Generally are there any classes or libraries that will assist with: 1. Easy creation of forms (fields and layout) 2. Validation of specific fields within the forms (server side not JS) 3. Decrease in time required to setup the forms pages any other comments are welcome. Hi! Zend framework has a wonderful solution to solve this task. You can download even the demo showing how to do this task Best regards, Alex. Both this class and Manuel Lemos' form generation class (from phpclasses.org) will create beautiful forms for you. However, you may find that the amount of [repetitive] typing you do will be equivalent or greater than simply creating the form by hand. The best solution would probably be a form you fill out which asks you about all the fields you want, and then generates the code to paint the form. There are commercial solutions which do this, and some (not that great) free solutions. I'm working on one myself, which will eventually be a sourceforge/freshmeat project. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms validation and creation- easier solution?
-Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 20 May 2009 16:09 To: php-general@lists.php.net Subject: Re: [PHP] Forms validation and creation- easier solution? On Wed, May 20, 2009 at 10:08:12AM +0300, Olexandr Heneralov wrote: 2009/5/20 Angelo Zanetti ang...@zlogic.co.za Hi all. We have done quite a few projects and we are looking to find better ways to implementing forms. Forms seem to be quite time consuming and repetitive. Generally are there any classes or libraries that will assist with: 1. Easy creation of forms (fields and layout) 2. Validation of specific fields within the forms (server side not JS) 3. Decrease in time required to setup the forms pages any other comments are welcome. Hi! Zend framework has a wonderful solution to solve this task. You can download even the demo showing how to do this task Best regards, Alex. Both this class and Manuel Lemos' form generation class (from phpclasses.org) will create beautiful forms for you. However, you may find that the amount of [repetitive] typing you do will be equivalent or greater than simply creating the form by hand. The best solution would probably be a form you fill out which asks you about all the fields you want, and then generates the code to paint the form. There are commercial solutions which do this, and some (not that great) free solutions. I'm working on one myself, which will eventually be a sourceforge/freshmeat project. Hi Paul. This sounds Great. Thanks for the advise. Just as a matter of interest do you know the location / path to Jay's class? I tried searching the archives but couldn't find it/ Thanks Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms validation and creation- easier solution?
On Wed, May 20, 2009 at 05:10:57PM +0200, Angelo Zanetti wrote: -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 20 May 2009 16:09 To: php-general@lists.php.net Subject: Re: [PHP] Forms validation and creation- easier solution? On Wed, May 20, 2009 at 10:08:12AM +0300, Olexandr Heneralov wrote: 2009/5/20 Angelo Zanetti ang...@zlogic.co.za Hi all. We have done quite a few projects and we are looking to find better ways to implementing forms. Forms seem to be quite time consuming and repetitive. Generally are there any classes or libraries that will assist with: 1. Easy creation of forms (fields and layout) 2. Validation of specific fields within the forms (server side not JS) 3. Decrease in time required to setup the forms pages any other comments are welcome. Hi! Zend framework has a wonderful solution to solve this task. You can download even the demo showing how to do this task Best regards, Alex. Both this class and Manuel Lemos' form generation class (from phpclasses.org) will create beautiful forms for you. However, you may find that the amount of [repetitive] typing you do will be equivalent or greater than simply creating the form by hand. The best solution would probably be a form you fill out which asks you about all the fields you want, and then generates the code to paint the form. There are commercial solutions which do this, and some (not that great) free solutions. I'm working on one myself, which will eventually be a sourceforge/freshmeat project. Hi Paul. This sounds Great. Thanks for the advise. Just as a matter of interest do you know the location / path to Jay's class? I tried searching the archives but couldn't find it/ Thanks Angelo You can search the archives by author, but I found it here: http://marc.info/?l=php-generalm=123003593813003w=2 Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and php
Mark Pashia schreef: I am fairly new to the php/mySQL combo and just noticed an unusual behavior and don't know where to find the answer to fix this. It is probably common knowledge, but not to a newbie. If I fill in the fields of a form and hit the enter key to submit the form, no variables seem to be passed along. If I use the submit button, everything works perfectly. It seems that other forms on the web work with the enter key just fine, so I am probably doing something to cause this yet I don't know what. seem? try the following line at the top of your submit script to see what is posted: var_dump($_GET, $_POST); I am hosted at hostgator.com and it has php version 4.4.4 and mySQL version 4.1.22-standard. Thanks, Mark Pashia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and php
On Jan 24, 2008 3:34 AM, Mark Pashia [EMAIL PROTECTED] wrote: If I fill in the fields of a form and hit the enter key to submit the form, no variables seem to be passed along. If I use the submit button, everything works perfectly. It seems that other forms on the web work with the enter key just fine, so I am probably doing something to cause this yet I don't know what. what does the html look like? i did a quick little experiment http://nathan.moxune.com/exampleForm.php and found if the type attribute of the input tag, used for the submission button, was 'submit', the enter key would not submit the form. however, if the value of the type attribute was 'button', pressing the enter button would submit the form. -nathan
Re: [PHP] forms and php
Some older browsers didn't send along the button name/value when you hit enter, for a one-button form... But I've never heard of one that failed to send anything at all... It's almost for sure a browser issue though -- PHP doesn't really *do* anything with the data it gets. It just stuffs it into $_POST / $_GET Ah. Did you remember to use method=post in your FORM tag?... :-) On Thu, January 24, 2008 2:34 am, Mark Pashia wrote: I am fairly new to the php/mySQL combo and just noticed an unusual behavior and don't know where to find the answer to fix this. It is probably common knowledge, but not to a newbie. If I fill in the fields of a form and hit the enter key to submit the form, no variables seem to be passed along. If I use the submit button, everything works perfectly. It seems that other forms on the web work with the enter key just fine, so I am probably doing something to cause this yet I don't know what. I am hosted at hostgator.com and it has php version 4.4.4 and mySQL version 4.1.22-standard. Thanks, Mark Pashia -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms class
On Mon, 2008-01-21 at 23:15 -0500, nihilism machine wrote: Why isnt this cleaning my form $_POST's class forms { var $UserInputClean; // Forms to variables function forms() { if (count($_POST) 0) { foreach($_POST as $curPostKey = $curPostVal) { $curPostKey = forms::CleanInput($curPostVal); That should probably be something along the lines: $_POST[$curPostKey] = forms::CleanInput( $curPostVal ); } } // Debug print_r($_POST); } // Clean XSS function CleanInput($UserInput) { $allowedtags = strongemaulliprehrblockquoteimgspan; $notallowedattribs = array(@javascript:|onclick|ondblclick| onmousedown|onmouseup .|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown| [EMAIL PROTECTED]); $changexssto = ''; $UserInput = preg_replace($notallowedattribs, $changexssto, $UserInput); $UserInput = strip_tags($text, $allowedtags); $UserInput = nl2br($UserInput); return $this-UserInputClean; WTF? BAD MONKEY!!! This function is called statically and so $this is NOT available. You probably meant to do the following though: return $UserInput; } } Other comments for you... Don't use hard tabs, use spaces (preferrably 4). Switch to vertically aligned braces it makes it easier for me to read your code ;) if( $foo ) { } Cheers, Rob -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and destroying values
It doesn't help to reset any values. The form data is being resent by the browser itself, just if the user presses the submit button again with the same data. What you could do is mabye use a session to see if the particular user has sent form data before. /Fredrik Thunberg Beauford skrev: Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and destroying values
El Fri, 12 Jan 2007 03:27:12 -0500 Beauford [EMAIL PROTECTED] escribió: Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks Maybe you can check the IP and see if it has already save the data or not. -- Miguel J. Jiménez Área de Internet/XSL [EMAIL PROTECTED] ISOTROL Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. Parque Tecnológico Cartuja '93, 41092 Sevilla. Teléfono: 955 036 800 - Fax: 955 036 849 http://www.isotrol.com Siempre intento salvar una vida al día. Normalmente es la mía (John Crichton, FARSCAPE 1x07) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and destroying values
Beauford wrote: Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. Perhaps a session variable that is set once the form is submitted. Depending on the data you could also look at having a primary key in the database. You could also have a hidden form variable that has some random value, once used, it cant be used again. clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and destroying values
This issue comes over and over again. The trick, as I learned from this list, is to send a redirect to the browser to a confirmation page, so the browser remembers the page redirected to and completely ignores the page that made the redirection so that neither a refresh nor going back to it can repeat the operation. So, if the database update has been succesful, use the header() function to send a 'location' header along with enough arguments in the URL to display a significant confirmation message but make sure that it is different from the URL that makes the database update. It will be this address, not the post that made the database update, that the browser will remember. Satyam - Original Message - From: Beauford [EMAIL PROTECTED] To: PHP php-general@lists.php.net Sent: Friday, January 12, 2007 9:27 AM Subject: [PHP] Forms and destroying values Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- 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] Forms and destroying values
So the answer is, there is no way to destroy the values. Question then, what is unset() used for as it doesn't seem to do anything? With a language as good as PHP I though there would be some way to do this. I have got a workaround, but that's exactly what it is - a work around. I am also still confused as to why giving them a null value doesn't work. Thanks to all. -Original Message- From: Satyam [mailto:[EMAIL PROTECTED] Sent: January 12, 2007 8:21 AM To: Beauford; PHP Subject: Re: [PHP] Forms and destroying values This issue comes over and over again. The trick, as I learned from this list, is to send a redirect to the browser to a confirmation page, so the browser remembers the page redirected to and completely ignores the page that made the redirection so that neither a refresh nor going back to it can repeat the operation. So, if the database update has been succesful, use the header() function to send a 'location' header along with enough arguments in the URL to display a significant confirmation message but make sure that it is different from the URL that makes the database update. It will be this address, not the post that made the database update, that the browser will remember. Satyam - Original Message - From: Beauford [EMAIL PROTECTED] To: PHP php-general@lists.php.net Sent: Friday, January 12, 2007 9:27 AM Subject: [PHP] Forms and destroying values Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- 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] Forms and destroying values
Beauford wrote: So the answer is, there is no way to destroy the values. Question then, what is unset() used for as it doesn't seem to do anything? With a language as good as PHP I though there would be some way to do this. I have got a workaround, but that's exactly what it is - a work around. I am also still confused as to why giving them a null value doesn't work. You need to get it clear in your head when PHP is sending data to the client and when it is not. Your assumption is basically that the data in $_POST is actually *connected* to the form displayed in the browser. This is not the case. When you change the contents of $_POST it has no effect on what the browser displays or uses since it's not actually sent to the browser unless you specifically output it in the form of a, erm, form. When the user hits refresh, or uses the back button it is up to the browser what it does. In the case of refresh, if the page being refreshed was created in response to a form being submitted the browser will ask the user if they want to resubmit the data. When using the back button the browser will usually use its cached copy of the page rather than hitting the server again. Hope that makes it clearer. -Stut -Original Message- From: Satyam [mailto:[EMAIL PROTECTED] Sent: January 12, 2007 8:21 AM To: Beauford; PHP Subject: Re: [PHP] Forms and destroying values This issue comes over and over again. The trick, as I learned from this list, is to send a redirect to the browser to a confirmation page, so the browser remembers the page redirected to and completely ignores the page that made the redirection so that neither a refresh nor going back to it can repeat the operation. So, if the database update has been succesful, use the header() function to send a 'location' header along with enough arguments in the URL to display a significant confirmation message but make sure that it is different from the URL that makes the database update. It will be this address, not the post that made the database update, that the browser will remember. Satyam - Original Message - From: Beauford [EMAIL PROTECTED] To: PHP php-general@lists.php.net Sent: Friday, January 12, 2007 9:27 AM Subject: [PHP] Forms and destroying values Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- 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] Forms and destroying values
On Fri, 2007-01-12 at 11:23 -0500, Beauford wrote: So the answer is, there is no way to destroy the values. Question then, what is unset() used for as it doesn't seem to do anything? With a language as good as PHP I though there would be some way to do this. I have got a workaround, but that's exactly what it is - a work around. I am also still confused as to why giving them a null value doesn't work. Because it's not PHP that won't destroy the values, it's the browser resubmitting the values. Thus PHP needs to work around the browser's resubmission of the form. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and destroying values
Beauford, I think you miss the point. The point is that the values are not remembered by the server at all (after the script finished running), so you don't have to explicitely destroy them. The unset() function is for session variables, which are remembered by the server even after the script finished running, that's their purpose. Your variables are not session variables but normal variables. BUT they are remembered by the browser, which may send them again to your script, that's why you get the same values again. So you have to apply some workaround to make the browser not send them again. Greets, Zoltán Németh 2007. 01. 12, péntek keltezéssel 11.23-kor Beauford ezt írta: So the answer is, there is no way to destroy the values. Question then, what is unset() used for as it doesn't seem to do anything? With a language as good as PHP I though there would be some way to do this. I have got a workaround, but that's exactly what it is - a work around. I am also still confused as to why giving them a null value doesn't work. Thanks to all. -Original Message- From: Satyam [mailto:[EMAIL PROTECTED] Sent: January 12, 2007 8:21 AM To: Beauford; PHP Subject: Re: [PHP] Forms and destroying values This issue comes over and over again. The trick, as I learned from this list, is to send a redirect to the browser to a confirmation page, so the browser remembers the page redirected to and completely ignores the page that made the redirection so that neither a refresh nor going back to it can repeat the operation. So, if the database update has been succesful, use the header() function to send a 'location' header along with enough arguments in the URL to display a significant confirmation message but make sure that it is different from the URL that makes the database update. It will be this address, not the post that made the database update, that the browser will remember. Satyam - Original Message - From: Beauford [EMAIL PROTECTED] To: PHP php-general@lists.php.net Sent: Friday, January 12, 2007 9:27 AM Subject: [PHP] Forms and destroying values Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- 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] Forms and destroying values
On Fri, 2007-01-12 at 17:36 +0100, Németh Zoltán wrote: Beauford, The unset() function is for session variables, which are remembered by the server even after the script finished running, that's their purpose. Your variables are not session variables but normal variables. Wrong! Please go read the manual for unset()... http://www.php.net/manual/en/function.unset.php Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and destroying values
2007. 01. 12, péntek keltezéssel 11.43-kor Robert Cummings ezt írta: On Fri, 2007-01-12 at 17:36 +0100, Németh Zoltán wrote: Beauford, The unset() function is for session variables, which are remembered by the server even after the script finished running, that's their purpose. Your variables are not session variables but normal variables. Wrong! Please go read the manual for unset()... http://www.php.net/manual/en/function.unset.php Cheers, Rob. You're right, sorry, I remembered incorrectly. Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and destroying values
As many have already replied to your question, what happens is that upon a refresh the browser is resending the original post variables again. The unset() does work, from the point of the unset() to the end of the script (when all variables except for session variables are unset), PHP will have completely forgotten about those values. But that does not affect the browser at all. On a refresh the browser will send the information again, unless it is tricked via a redirection command to believe the URL used for the post is obsolete. Then, what the browser will do is to remember the URL it was redirected to and drop the 'obsolete' URL so, when the user does a refresh, the browser will be smart enough to go to the 'updated' (the redirected-to) URL instead of the original 'obsolete' one and thus will get the confirmation page again, but without passing through the database transaction. Satyam - Original Message - From: Beauford [EMAIL PROTECTED] To: 'PHP' php-general@lists.php.net Sent: Friday, January 12, 2007 5:23 PM Subject: RE: [PHP] Forms and destroying values So the answer is, there is no way to destroy the values. Question then, what is unset() used for as it doesn't seem to do anything? With a language as good as PHP I though there would be some way to do this. I have got a workaround, but that's exactly what it is - a work around. I am also still confused as to why giving them a null value doesn't work. Thanks to all. -Original Message- From: Satyam [mailto:[EMAIL PROTECTED] Sent: January 12, 2007 8:21 AM To: Beauford; PHP Subject: Re: [PHP] Forms and destroying values This issue comes over and over again. The trick, as I learned from this list, is to send a redirect to the browser to a confirmation page, so the browser remembers the page redirected to and completely ignores the page that made the redirection so that neither a refresh nor going back to it can repeat the operation. So, if the database update has been succesful, use the header() function to send a 'location' header along with enough arguments in the URL to display a significant confirmation message but make sure that it is different from the URL that makes the database update. It will be this address, not the post that made the database update, that the browser will remember. Satyam - Original Message - From: Beauford [EMAIL PROTECTED] To: PHP php-general@lists.php.net Sent: Friday, January 12, 2007 9:27 AM Subject: [PHP] Forms and destroying values Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- 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] Forms and destroying values
Thanks, a little confusing there. You would think though that once the info is transmitted by the browser it would be forgotten by the browser. Anyway, I do have a work around, and since PHP can't do anything about what the browser does, this will have to suffice. Thanks all. -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: January 12, 2007 11:38 AM To: Beauford Cc: 'PHP' Subject: Re: [PHP] Forms and destroying values Beauford wrote: So the answer is, there is no way to destroy the values. Question then, what is unset() used for as it doesn't seem to do anything? With a language as good as PHP I though there would be some way to do this. I have got a workaround, but that's exactly what it is - a work around. I am also still confused as to why giving them a null value doesn't work. You need to get it clear in your head when PHP is sending data to the client and when it is not. Your assumption is basically that the data in $_POST is actually *connected* to the form displayed in the browser. This is not the case. When you change the contents of $_POST it has no effect on what the browser displays or uses since it's not actually sent to the browser unless you specifically output it in the form of a, erm, form. When the user hits refresh, or uses the back button it is up to the browser what it does. In the case of refresh, if the page being refreshed was created in response to a form being submitted the browser will ask the user if they want to resubmit the data. When using the back button the browser will usually use its cached copy of the page rather than hitting the server again. Hope that makes it clearer. -Stut -Original Message- From: Satyam [mailto:[EMAIL PROTECTED] Sent: January 12, 2007 8:21 AM To: Beauford; PHP Subject: Re: [PHP] Forms and destroying values This issue comes over and over again. The trick, as I learned from this list, is to send a redirect to the browser to a confirmation page, so the browser remembers the page redirected to and completely ignores the page that made the redirection so that neither a refresh nor going back to it can repeat the operation. So, if the database update has been succesful, use the header() function to send a 'location' header along with enough arguments in the URL to display a significant confirmation message but make sure that it is different from the URL that makes the database update. It will be this address, not the post that made the database update, that the browser will remember. Satyam - Original Message - From: Beauford [EMAIL PROTECTED] To: PHP php-general@lists.php.net Sent: Friday, January 12, 2007 9:27 AM Subject: [PHP] Forms and destroying values Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ; or $_POST['var'] = ; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- 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] forms usage in web pages
On Sun, 2006-10-29 at 13:15 +0530, Karthi S wrote: hi, i am newbie to web programming. i have a basic doubt in using forms. Is it advisable to use multiple forms performing various functions in a single web page. what are the pros and cons of using that. Please forgive me if this is not the right mailing list to post this question. But help me out in clarifying this basic doubt. thanks in advance As long as the purpose is clear then I don't think you will have a problem with multiple forms on a single web page. For instance, it's quite common to see a search form on every page regardless of what other forms might be present. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms usage in web pages
There's nothing wrong with multiple forms on a single page, as long as all id attributes in all elements are unique on the entire page, not just within the form. Just make sure that each form is self-contained with its own submit button and such. Only the form whose submit button is clicked will get submitted by the browser. Whether or not you want to use multiple forms for a given set of tasks or multiple submit buttons in a single form (which you can then test to see which was clicked) will depend on what it is you're doing. Both are perfectly legitimate ways of doing things, depending on what things you're doing. On Sunday 29 October 2006 01:45, Karthi S wrote: hi, i am newbie to web programming. i have a basic doubt in using forms. Is it advisable to use multiple forms performing various functions in a single web page. what are the pros and cons of using that. Please forgive me if this is not the right mailing list to post this question. But help me out in clarifying this basic doubt. thanks in advance Karthi -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms usage in web pages
Is anyone else getting multiple copies of posts? On Oct 29, 2006, at 9:52 AM, Larry Garfield wrote: There's nothing wrong with multiple forms on a single page, as long as all id attributes in all elements are unique on the entire page, not just within the form. Just make sure that each form is self-contained with its own submit button and such. Only the form whose submit button is clicked will get submitted by the browser. Whether or not you want to use multiple forms for a given set of tasks or multiple submit buttons in a single form (which you can then test to see which was clicked) will depend on what it is you're doing. Both are perfectly legitimate ways of doing things, depending on what things you're doing. On Sunday 29 October 2006 01:45, Karthi S wrote: hi, i am newbie to web programming. i have a basic doubt in using forms. Is it advisable to use multiple forms performing various functions in a single web page. what are the pros and cons of using that. Please forgive me if this is not the right mailing list to post this question. But help me out in clarifying this basic doubt. thanks in advance Karthi -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- 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] forms usage in web pages
yes, but then again, I've already mentioned this, and have seen some posts now an then mention the subject... :) On Sunday 29 October 2006 21:26, Ed Lazor wrote: Is anyone else getting multiple copies of posts? On Oct 29, 2006, at 9:52 AM, Larry Garfield wrote: There's nothing wrong with multiple forms on a single page, as long as all id attributes in all elements are unique on the entire page, not just within the form. Just make sure that each form is self-contained with its own submit button and such. Only the form whose submit button is clicked will get submitted by the browser. Whether or not you want to use multiple forms for a given set of tasks or multiple submit buttons in a single form (which you can then test to see which was clicked) will depend on what it is you're doing. Both are perfectly legitimate ways of doing things, depending on what things you're doing. On Sunday 29 October 2006 01:45, Karthi S wrote: hi, i am newbie to web programming. i have a basic doubt in using forms. Is it advisable to use multiple forms performing various functions in a single web page. what are the pros and cons of using that. Please forgive me if this is not the right mailing list to post this question. But help me out in clarifying this basic doubt. thanks in advance Karthi -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and dynamic creation and unique field names
On Thu, April 27, 2006 9:56 am, Jason Gerfen wrote: I have come upon a problem and am not sure how to go about resolving it. I have an web form which is generated dynamically from an imported file and I am not sure how I can loop over the resulting post variables within the global $_POST array due to the array keys not being numeric. Any pointers are appreciated. function array_dump($data){ if (is_array($data)){ foreach($data as $key = $value) echo $key: ; array_dump($value); echo br /\n; } } else echo $data; } array_dump($_POST); -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and dynamic creation and unique field names
Jason Gerfen wrote: I have come upon a problem and am not sure how to go about resolving it. I have an web form which is generated dynamically from an imported file and I am not sure how I can loop over the resulting post variables within the global $_POST array due to the array keys not being numeric. Any pointers are appreciated. You will never be ready for me. ~ Me Hahah... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and dynamic creation and unique field names
Martin Zvarík wrote: Jason Gerfen wrote: I have come upon a problem and am not sure how to go about resolving it. I have an web form which is generated dynamically from an imported file and I am not sure how I can loop over the resulting post variables within the global $_POST array due to the array keys not being numeric. Any pointers are appreciated. You will never be ready for me. ~ Me Hahah... HAHA... -- Jason Gerfen You will never be ready for me. ~ Me -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and dynamic creation and unique field names
Jason Gerfen schrieb: Martin Zvarík wrote: Jason Gerfen wrote: I have come upon a problem and am not sure how to go about resolving it. I have an web form which is generated dynamically from an imported file and I am not sure how I can loop over the resulting post variables within the global $_POST array due to the array keys not being numeric. Any pointers are appreciated. You will never be ready for me. ~ Me Hahah... HAHA... O_o -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] forms and variables?
[snip] Probably a stupid one but anyway... In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? Example: //point to the variable with something like or somenthing??? $AddNew.SomeVar form name=AddNew method=post action=? $PHP_SELF ? $SomeVar = Add; /form form name=DeleteOld method=post action=? $PHP_SELF ? $SomeVar = Del; /form Or do I just have name the variables uniquely? [/snip] You could write a function...looks like you're trying to do something similar to DOM. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and variables?
take the following code and do some experimentation: ? echo 'pre'; echo POST vars: \n; var_dump($_POST); echo GET vars: \n; var_dump($_GET); echo '/pre'; ? stick that in your page that contain the form and start playing with different form fields, different form fields names, etc, etc - everytime you submit you'll know see what's being submitted. enjoy William Stokes wrote: Hello, Probably a stupid one but anyway... In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? Example: //point to the variable with something like or somenthing??? $AddNew.SomeVar this is not asp.NET/asp.NOT, so no to that question. god only knows what you mean by the form examples below... form name=AddNew method=post action=? $PHP_SELF ? $SomeVar = Add; /form form name=DeleteOld method=post action=? $PHP_SELF ? $SomeVar = Del; /form Or do I just have name the variables uniquely? I would, in general, recommend calling every $x. ;-) Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and variables?
At 3:45 PM +0300 4/21/06, William Stokes wrote: Hello, Probably a stupid one but anyway... In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? Example: //point to the variable with something like or somenthing??? $AddNew.SomeVar form name=AddNew method=post action=? $PHP_SELF ? $SomeVar = Add; /form form name=DeleteOld method=post action=? $PHP_SELF ? $SomeVar = Del; /form Or do I just have name the variables uniquely? Thanks -Will -Will: Sure, you're almost there, just make a hidden variable $whichform and use it like so: form name=AddNew method=post action=? $PHP_SELF ? input type=hidden name=whichform value=add /form form name=DeleteOld method=post action=? $PHP_SELF ? input type=hidden name=whichform value=del /form HTH's tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and variables?
On Fri, April 21, 2006 7:45 am, William Stokes wrote: In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? The FORM name attribute was an add-on for Javascript client-side. It is not transmitted by HTTP. PHP never sees it. Or do I just have name the variables uniquely? Yes. Or you could just add ONE new INPUT in each form to tell you which FORM was used: INPUT TYPE=HIDDEN NAME=FORM VALUE=AddNew / Or you could have just ONE form and use buttons with name for your INPUTs: form name=irrelevant ... input type=submit name=AddNew value=Add / input type=submit name=DeleteOld value=Del / /form The button the user clicked on is sent as a variable with HTTP. EXCEPTIONS: If there is only ONE submit button, and if the user hits Enter (aka Return) instead of actually clicking on the button, then some browser do not send the button name/value. If you use JavaScript to do the submit, it's your problem to add whatever inputs you need in JavaScript to make things work... As well as anything in JavaScript works, anyway. Or you could have the FORMs have different ACTION attributes so you know which form sent the data because you have scripts dedicated to a specific purpose instead of some monolithic mess trying to be-all do-all end-all. Or you can use arrays in the NAME attributes to organize things in some cases -- probably not in this particular instance, but keep it in mind for INPUT elements within the same form. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] forms
[snip] Hi can any one show me how make another form appear below another once the 1st form has been submitted. [/snip] post to PHP_SELF and test for population of original form parts if('' != $_POST['name'] etc.){ echo all of the other form parts; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms
Mark wrote: Hi can any one show me how make another form appear below another once the 1st form has been submitted. [not really a PHP solution...] You can do like this: the 'SUBMIT' button of the first form only makes visible the (hidden) DIV where the second form is, and only *that* 'SUBMIT' button actually submits the form. CSS reference: http://www.w3schools.com/css/css_reference.asp HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms
Try reading the PHP FAQ and looking for the answer about a generic form response using $_POST. On Mon, May 2, 2005 9:09 pm, Lisa A said: Does anyone know of a good easy php script or Form that we can use with Front Page. We need a form to get results, that actually sends the results in a format that is easy to read. Not all run together with no spaces, etc. like the Front Page forms. Thanks, Lisa A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
Does anyone know how to get a particular option to display in a drop menu? select name=category id=category option selected=true value=Option ValueOption Value/option option value=line-/option option value=value1 value1/option option value=value2 value2 /option option value=value3 value3/option option value=value4 value4/option /select add selected=selected to the option option value=value4 selected=selectedvalue4/option -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
On Mon, 21 Mar 2005 10:04:23 -0600, Marquez Design [EMAIL PROTECTED] wrote: Greetings, Does anyone know how to get a particular option to display in a drop menu? Perhaps, do db query first, then for each option (perhaps as a foreach or something): echo option name=\whatever\ value=\\; if (!(strcmp($required_value, $db_result))) { echo selected; } echo ; cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
At 12:04 PM 3/21/2005, Marquez Design wrote: Greetings, Does anyone know how to get a particular option to display in a drop menu? select name=category id=category option selected=true value=Option ValueOption Value/option option value=line-/option option value=value1 value1/option option value=value2 value2 /option option value=value3 value3/option option value=value4 value4/option /select The user has previously selected a category. That information is in the database. Here they are editing the record. What I would like is for the option that was selected and is in the database to be displayed as the selectd option. Does anyone know how I can do this, or can you point me in the right direction? Thank you, -- Steve Marquez Marquez Design Steve, These can be a PITA. Here's how I've done it. 1. Create a function to determine which is selected: function is_selected( $option_expression ) { if ($option_expression) { $retval = selected; } else { $retval = ; } return $retval; } // end of function is_selected 2. Build your list of selection, in this case a list of classifications fetched from a database; $option_class is the variable holding the list of options: $sql = select * from class; $result = mysql_query( $sql ); while( $row = mysql_fetch_array( $result ) ) { $nClassKey = $row[nClassKey]; $cClass = $row[cClass]; $selectval = is_selected( $nClassKey == $nClass ); $option_class .= option value = \$nClassKey\ $selectval $cClass/option; } // end while $row = mysql_fetch... 3. Then display it this way in the form: Select name=nClass ? echo $option_class ? /select Hope this is helpful - Miles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
The way I did: # taking values from DB $query = mysql_query(select * from VALUES) $result = mysql_fet_array($query); #create an array of all values of dropdow menu $values = arra('value1', 'value2', 'value3', 'value4'); # create SELECT form using for loop echo 'select name=category id=categoryoption selected=true value=Option ValueOption Value/optionoption value=line-/option'; for($i=0; $icount($values); $i++) { # if value from DB is equal to value in SELECT form set it as SELECTED $selected = ($result['value_from_db'] == $values[$i]) ? 'SELECTED' : ''; echo 'option value='.$values[$i].' '.$selected.' '.$values[$i].'/option'; } echo '/select'; and it work just fine for me :) -afan Marquez Design wrote: Greetings, Does anyone know how to get a particular option to display in a drop menu? select name=category id=category option selected=true value=Option ValueOption Value/option option value=line-/option option value=value1 value1/option option value=value2 value2 /option option value=value3 value3/option option value=value4 value4/option /select The user has previously selected a category. That information is in the database. Here they are editing the record. What I would like is for the option that was selected and is in the database to be displayed as the selectd option. Does anyone know how I can do this, or can you point me in the right direction? Thank you, -- Steve Marquez Marquez Design -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms on PHP
Refer to the following line numbers: 01 ?php 02 // Start of PHP code - Extract values from form. 03 /* Other values read */ 04 $n=$_POST['n']; 05 06 // Pass the data from the form to lightcurve_csharp 07 $command=./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n; 08 $result=`$command`; 09 10 $form_submitted=$_POST['form_sumbitted']; 11 if (isset($form_submitted)) { 12 if ($form_submitted) { 13 echo 'The form has been submittedbr'; 14 unset($form_submitted); 15 } 16 } else 17 echo 'The form has not been submittedbr'; When the user first load the page, no data was posted. So there was no $_POST['form_sumbitted'] available. Line 10 will cause $form_submitted to contain the NULL value (I think). $form_submitted will evaluate to FALSE at line 12. Thus it will not display any message. By the way, by doing line 10, $form_submitted would have been set regardless whether there is $_POST['form_sumbitted'], and line 11 will evaluate to TRUE always. Thus you will never ever see the 'form not been submitted' message. Anyway, when you posted for the first time, $_POST['form_sumbitted'] is available. The 'The form has been submittedbr' message will be printed. After that, when you press Reload button on the browser, the post data will once again be sent from the user. (This is the behaviour of reloading a posted page. In Internet Explorer there should be a message dialog box asking the user whether to resend form data in order to refresh.) Reposting the data during the reload means that there will be $_POST['form_sumbitted'], thus once again the 'form hass been submitted' message. In order to prevent this from happening, you should do a header('Location: success-page.php') on a successful submit. This is so that at the redirected page, the user would not have resent data even if he press the Reload button. Hope this helps -Leon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms on PHP
PHPDiscuss - PHP Newsgroups and mailing lists wrote: I am new to this or any newsgroup in PHP, as well as PHP itself, so this question is probably rather elementary. I have a form which on clicking on the Submit button calls up a compiled program on the server that is executed and writes output to a file. This file is then read by the PHP script and passed on for other processes. Yikes! What if two guys surf to the same page AT THE SAME TIME? Is this all being taken care of? Or is this an admin page that only one guy ever uses, and he *KNOWS* not to run it in two different browsers at the same time? And you'll *NEVER* try to run it for testing while he's trying to run it for real? And... This scenario is rife with potential problems. When the page is first loaded, it knows that the Submit button has not been clicked, and after clicking the button it knows, which is of course what we want. The problem is that subsequently it always thinks the button has been clicked, even if the reload button on the browser has been clicked. When I hit re-load, you get back *exactly* the same thing I sent you last time. $_POST and everything. If you want to do something *different* then you need to keep a record of the fact that I already POSTed this data. For example, you could embed a http://php.net/uniqid in your FORM in a HIDDEN INPUT, and then store that in a database, and if I POST again, you can do whatever you want. Don't call that external program, and just read the file from the previous action but with an added notification that I'm reading old data, or send me a different output, or ... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms on PHP
Leon Poon wrote: Refer to the following line numbers: 01 ?php 02 // Start of PHP code - Extract values from form. 03 /* Other values read */ 04 $n=$_POST['n']; 05 06 // Pass the data from the form to lightcurve_csharp 07 $command=./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n; 08 $result=`$command`; 09 10 $form_submitted=$_POST['form_sumbitted']; 11 if (isset($form_submitted)) { 12 if ($form_submitted) { 13 echo 'The form has been submittedbr'; 14 unset($form_submitted); 15 } 16 } else 17 echo 'The form has not been submittedbr'; When the user first load the page, no data was posted. So there was no $_POST['form_sumbitted'] available. Line 10 will cause $form_submitted to contain the NULL value (I think). $form_submitted will evaluate to FALSE at line 12. Thus it will not display any message. By the way, by doing line 10, $form_submitted would have been set regardless whether there is $_POST['form_sumbitted'], and line 11 will evaluate to TRUE always. Thus you will never ever see the 'form not been submitted' message. Anyway, when you posted for the first time, $_POST['form_sumbitted'] is available. The 'The form has been submittedbr' message will be printed. After that, when you press Reload button on the browser, the post data will once again be sent from the user. (This is the behaviour of reloading a posted page. In Internet Explorer there should be a message dialog box asking the user whether to resend form data in order to refresh.) Reposting the data during the reload means that there will be $_POST['form_sumbitted'], thus once again the 'form hass been submitted' message. In order to prevent this from happening, you should do a header('Location: success-page.php') on a successful submit. This is so that at the redirected page, the user would not have resent data even if he press the Reload button. Hope this helps -Leon Many thanks - at the top of the file I put in the code: if ($_POST['submit']) header('Location: .../submitted.php'); where further down in the form I have name=submit for the submit button. This goes to a new page submitted.php. The code is in fact now at http://proteus.as.arizona.edu/~csharp/lightcurved.php . No doubt there is still a way of writing back to the original page after the submit button has been clicked, but I can't see an easy way, so this will have to do for now. A work-around is to do it in frames, and write to a frame at the bottom so that it appears to be in the same page. Christopher Sharp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and viewing Text Area
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 09 December 2004 22:41, Ben C wrote: I have a form which has a text box which then stores in MySQL. When I write seperate paragraphs and try and then view what I wrote it lumps it all together in one paragraph when I echo. I am sure I am doing something simply wrong. Anyone have any ideas? echo nl2br(htmlspecialchars($text)) is my usual mantra for this. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and viewing Text Area
--- Ford, Mike [EMAIL PROTECTED] wrote: echo nl2br(htmlspecialchars($text)) is my usual mantra for this. nl2br will give you back the correct formatting, but will leave br/'s in the output. I just went through this issue the other day, what I found worked for me was: htmlspecialchars('string'),ENT_NOQUOTES); Note- check the available parameters for htmlspecialchars. I used ENT_NOQUOTES because I wanted to preserve the single and double quotes in my text. Hope this helps. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms In PHP
Wil Hitchman wrote: I created a web form in PHP and used a couple of email addresses. The only email address that worked when I submitted to the form (for testing purposes) was my Yahoo address. My AOL, hotmail and other work addresses did not work. Can someone tell me why? Technically, To: is only supposed to allow one (1) email address. Assuming you are using sendmail or one of its popular drop-in replacements, they will support To: with multiple emails, but it's not RFC that they have to. So while I don't think it's the real problem, you're better off using Cc: headers in the optional fourth argument to http://php.net/mail to be standards-based. Most likely, however, the email you sent was flagged as spam by AOL and hotmail, but not yahoo. So the email got sent just fine, but they throw it out before you ever saw it. You can research how spam filters work to make your email look less like spam and tray again. Unless you plan on sending spam, in which case you should just quit :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and viewing Text Area
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 10 December 2004 11:30, Stuart Felenstein wrote: --- Ford, Mike [EMAIL PROTECTED] wrote: echo nl2br(htmlspecialchars($text)) is my usual mantra for this. nl2br will give you back the correct formatting, but will leave br/'s in the output. OK, yes, a case of engage brain before operating keyboard: in a textarea, that may be the case; if you're just sending it out as part of straight HTML, my mantra is right! Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and viewing Text Area
Ben C wrote: I have a form which has a text box which then stores in MySQL. When I write seperate paragraphs and try and then view what I wrote it lumps it all together in one paragraph when I echo. I am sure I am doing something simply wrong. Anyone have any ideas? put pre tag around it. and don't forget htmlspecialchars(): echo 'pre' . htmlspecialchars($input) . '/pre'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and viewing Text Area
Ben C wrote: I have a form which has a text box which then stores in MySQL. When I write seperate paragraphs and try and then view what I wrote it lumps it all together in one paragraph when I echo. I am sure I am doing something simply wrong. Anyone have any ideas? The line breaks are preserved. If you look at the HTML source of your page, you'll see that. HTML does not render line breaks, though, you need br / tags. So using nl2br() or something similar would work. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms
What is a connect_db file? - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 11:33 PM Subject: Re: [PHP] forms Thanks-- i got that going-GREAT ! now i have a form that creates the database and tables, any ideas how i can get this info to change the connect_db file so that it doesnt have to be done manually. Minuk Choi [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] try this : $link = mysql_connect($host, $user, $pass); Note : No SINGLE quotes. In PHP, quotations are as follows $host = 'localhost'; $a = '$host'; $b = $host; echo $a; that prints $host echo $b; that prints localhost. HTH -Minuk - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 10:23 PM Subject: [PHP] forms/variables/create database hi, does anyone know why this is not working, i have married 2 pieces of code together and i have no idea what im doing--any help is appreciated. I get an error that says it cant find the host--$host so obviusly its not passing it from the form. / ?php $host = $_POST['host']; $user = $_POST['user']; $pass = $_POST['pass']; $db_name = $_POST['db-name']; $link = mysql_connect('$host', '$user', '$pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } if (mysql_create_db('db_name')) { echo Database created successfully\n; } else { echo 'Error creating database: ' . mysql_error() . \n; } ? / -- 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] forms/variables/create database
try this : $link = mysql_connect($host, $user, $pass); Note : No SINGLE quotes. In PHP, quotations are as follows $host = 'localhost'; $a = '$host'; $b = $host; echo $a; that prints $host echo $b; that prints localhost. HTH -Minuk - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 10:23 PM Subject: [PHP] forms/variables/create database hi, does anyone know why this is not working, i have married 2 pieces of code together and i have no idea what im doing--any help is appreciated. I get an error that says it cant find the host--$host so obviusly its not passing it from the form. / ?php $host = $_POST['host']; $user = $_POST['user']; $pass = $_POST['pass']; $db_name = $_POST['db-name']; $link = mysql_connect('$host', '$user', '$pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } if (mysql_create_db('db_name')) { echo Database created successfully\n; } else { echo 'Error creating database: ' . mysql_error() . \n; } ? / -- 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] forms
Thanks-- i got that going-GREAT ! now i have a form that creates the database and tables, any ideas how i can get this info to change the connect_db file so that it doesnt have to be done manually. Minuk Choi [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] try this : $link = mysql_connect($host, $user, $pass); Note : No SINGLE quotes. In PHP, quotations are as follows $host = 'localhost'; $a = '$host'; $b = $host; echo $a; that prints $host echo $b; that prints localhost. HTH -Minuk - Original Message - From: bigmark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 10, 2004 10:23 PM Subject: [PHP] forms/variables/create database hi, does anyone know why this is not working, i have married 2 pieces of code together and i have no idea what im doing--any help is appreciated. I get an error that says it cant find the host--$host so obviusly its not passing it from the form. / ?php $host = $_POST['host']; $user = $_POST['user']; $pass = $_POST['pass']; $db_name = $_POST['db-name']; $link = mysql_connect('$host', '$user', '$pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } if (mysql_create_db('db_name')) { echo Database created successfully\n; } else { echo 'Error creating database: ' . mysql_error() . \n; } ? / -- 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] forms
Thanks-- i got that going-GREAT ! now i have a form that creates the database and tables, any ideas how i can get this info to change the connect_db file so that it doesnt have to be done manually. See fopen(), fwrite(), and fclose(): http://php.net/manual/en/ref.filesystem.php Not sure exactly what you're doing, but having PHP (via http) use a mysql account with create privileges and write your configuration files is a gaping security hole - fine for a personal/internal/ephemeral/testing project, but terrible security practice for any application or site that faces the outside world. -- michal migurski- contact info, blog, and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms, ListBoxes, Validating Errors.
Hello Kacey, Friday, January 16, 2004, 11:33:22 AM, you wrote: KAM What I have is an issue with posting forms with Dynamic ListBoxes. KAM What happens is when you fill the form out, and hit submit, it validates the KAM form .. if there is a required field not filled out, it comes back and gives KAM an error. All the textfields have all the information and the Static KAM ListBoxes have all the information they filled out... But if the user KAM selected a STATE (which is pulled dynamically) it will reset this box to the KAM default setting. It will reset it when the page reloads with the error message, yes? KAM function build_states_tree($output, $preselected) { You already have the preselected variable in your function, so why not just pass in whatever the user previously selected back to it again? (i.e. over-ride whatever the initial preselected was?) -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and mysql
Hi, Tuesday, December 2, 2003, 9:54:33 PM, you wrote: B Hi i am very new to PHP so need some help ! B i have a form which allows the user to put in 2 team names and then displays B them, at the moment it displays them side by side but i need to insert V B (versus) in the middle--how can i do that. B I am guessing it goes in the lines of the code below somewhere, This code B originally displayed someones input for --first name,last name and address B so i have adapted it. Is there anyway to have the 'address' field display a B set value as in a V , at the moment i have removed that part but the table B field is still there, i have just hidden the form input. B $result = mysql_query(SELECT * FROM teams,$db); B while ($myrow = mysql_fetch_array($result)) { B printf(a href=\%s?id=%s\%s %s/a \n, $PHP_SELF, $myrow[id], B $myrow[teama],$myrow[teamb]); Just stick a V between as in ..%s V %s ... printf will ignore anything without a % before it and just copy it to the output -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and Arrays
On 28 November 2003 14:36, Dave Carrera wrote: Hi List, I have a dynamically generated form with inputs with names that create arrays i.e.: input name=fname[] input name=flab[] input name=fplc[] The extra bits for the inputs are omitted deliberately for this question but exists in the form i.e.: size, value, type. And these are repeated as many time as required. Thus they are generating arrays called: Fname0 Flab0 Fplc0 Fname1 Flab1 Fplc1 Fname2 Flab2 Fplc2 Sorry to be pedantic, but, no, they are generating arrays called fname, flab, and fplc. The elements of these arrays are fname[0], fname[1], fname[2]..., flab[0], flab[1]... etc. And so on as per the num of dynamically generated input lines for the form. My question is This describes one way of handling the arrays: how can I treat each array separately and then move on to the next until end ? SO the output would be : ... but this illustrates exactly the opposite way of treating them: fname0 = value flab0 = value fplc0 = value fname1 = value flab1 = value fplc1 = value fname2 = value flab2 = value fplc2 = value So which is it you want? Presumably, your example output is correct and the description is wrong, and what you really want to do is address the first element of each array, then the second element of each array, and so on. In which case, you've pretty much described how to do it in your example output, and your only remaining problem is how to find out how long the arrays are -- for which I recommend you take a look at http://www.php.net/count. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and Arrays
Thank you for clearing up my rather lame explanation. So how can I process $_POST[dynamic-name][user-entered-value] arrays to give me my desired output: fname0 = value flab0 = value fplc0 = value fname1 = value flab1 = value fplc1 = value fname2 = value flab2 = value fplc2 = value Any help our example will be most appreciated. Dave C -Original Message- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: 28 November 2003 14:50 To: 'Dave Carrera'; [EMAIL PROTECTED] Subject: RE: [PHP] Forms and Arrays On 28 November 2003 14:36, Dave Carrera wrote: Hi List, I have a dynamically generated form with inputs with names that create arrays i.e.: input name=fname[] input name=flab[] input name=fplc[] The extra bits for the inputs are omitted deliberately for this question but exists in the form i.e.: size, value, type. And these are repeated as many time as required. Thus they are generating arrays called: Fname0 Flab0 Fplc0 Fname1 Flab1 Fplc1 Fname2 Flab2 Fplc2 Sorry to be pedantic, but, no, they are generating arrays called fname, flab, and fplc. The elements of these arrays are fname[0], fname[1], fname[2]..., flab[0], flab[1]... etc. And so on as per the num of dynamically generated input lines for the form. My question is This describes one way of handling the arrays: how can I treat each array separately and then move on to the next until end ? SO the output would be : ... but this illustrates exactly the opposite way of treating them: fname0 = value flab0 = value fplc0 = value fname1 = value flab1 = value fplc1 = value fname2 = value flab2 = value fplc2 = value So which is it you want? Presumably, your example output is correct and the description is wrong, and what you really want to do is address the first element of each array, then the second element of each array, and so on. In which case, you've pretty much described how to do it in your example output, and your only remaining problem is how to find out how long the arrays are -- for which I recommend you take a look at http://www.php.net/count. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and Arrays
On 28 November 2003 17:22, Dave Carrera wrote: Thank you for clearing up my rather lame explanation. So how can I process $_POST[dynamic-name][user-entered-value] arrays to give me my desired output: fname0 = value flab0 = value fplc0 = value fname1 = value flab1 = value fplc1 = value fname2 = value flab2 = value fplc2 = value Any help our example will be most appreciated. Well, like I say, you've pretty much written it there. You need a loop which outputs one line on each iteration -- the body of the loop will look something like: echo fname$i = {$_POST['fname'][$i]} . flab$i = {$_POST['flab'][$i]} . fplc$i = {$_POST['fplc'][$i]} There's any number of ways you could write the loop so that $i has the approriate value on each iteration, but a for() loop would probably be the conventional one. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and Arrays
Dave - ...and then Dave Carrera said... % % Thank you for clearing up my rather lame explanation. % % So how can I process $_POST[dynamic-name][user-entered-value] arrays to give % me my desired output: % % fname0 = value flab0 = value fplc0 = value Do you really want a variable called $fname0 and another $fname1 and so on, or do you just want this output? It seems to me that you probably want the latter, so you need only walk through your array: foreach ( array_keys($_POST[fname]) as $k ) { print fname$k = {$_POST[fname][$k]} ; print flab$k = {$_POST[flab][$k]} ; print fplc$k = {$_POST[fplc][$k]}br\n ; } HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
RE: [PHP] Forms
[snip] This is probably more of a javascript question but thought someone here might have an answer. I have a form in a pop up windoe I want this form data to be submited to the window that opened the popup - how can I do this? I have tried setting the target attribute on the form tag to window.opener() but that just opens a new window. Any ideas? [/snip] There are several in archives as this question comes up once a week or more often http://marc.theaimsgroup.com/?l=php-general -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
Matthew Oatham wrote: Hi, This is probably more of a javascript question but thought someone here might have an answer. I have a form in a pop up windoe I want this form data to be submited to the window that opened the popup - how can I do this? I have tried setting the target attribute on the form tag to window.opener() but that just opens a new window. Any ideas? Thanks It is JavaScript. You're on the right track with window.opener(), but that can't be the target. I believe you're going to have to do something with an onSubmit(), and pass the data that way. -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
Matthew Oatham wrote: Hi, This is probably more of a javascript question but thought someone here might have an answer. I have a form in a pop up windoe I want this form data to be submited to the window that opened the popup - how can I do this? I have tried setting the target attribute on the form tag to window.opener() but that just opens a new window. Any ideas? The simplest way is to name your main window with javascript: window.name = 'domainMainWindow'; Then you can use the name as target in your form. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
If I understand your question correctly it sounds like you want to populate a database on Server A with data residing in a database on server B via a form hosted on server A *grin*. Obviously this is tedious, and if there are a lot of entries then I would suggest writing a script to populate and submit the form automatically. If you are lucky everything will be done via HTML GET method (URL parameters); however, it is more likely that it uses the POST method. You can do some reading into posting data via HTML request headers, or you can look and see if there is a class that does what you want in PEAR or PHP Classes. HTH, Rob. On Tue, 2003-08-12 at 10:18, Kris Reid wrote: I'm having trouble explaining this so please bare with me. Say there is a form hosted on server A on a web page Something simple like form action=submit.php method=post onSubmit=window.onunload=null; input name=data size=25 value= //td input type=submit value=submit / /form I have the data on server B in a mysql database that needs to be inserted via that form. I have written a script that will grab one record and submit it via the form. The only problem is I have to keep going back and refreshing my web page to get it to submit another record. Is there a way of doing this? Please note I have no access to Server A so I can't just edit there database. Does this make sense? :) Thanks Kris -- .-. | Worlds of Carnage - http://www.wocmud.org | :-: | Come visit a world of myth and legend where | | fantastical creatures come to life and the | | stuff of nightmares grasp for your soul.| `-' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
- Original Message - From: Robert Cummings [EMAIL PROTECTED] To: Kris Reid [EMAIL PROTECTED] Cc: PHP List [EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 12:25 AM Subject: Re: [PHP] Forms If I understand your question correctly it sounds like you want to populate a database on Server A with data residing in a database on server B via a form hosted on server A *grin*. Obviously this is tedious, and if there are a lot of entries then I would suggest writing a script to populate and submit the form automatically. If you are lucky everything will be done via HTML GET method (URL parameters); however, it is more likely that it uses the POST method. You can do some reading into posting data via HTML request headers, or you can look and see if there is a class that does what you want in PEAR or PHP Classes. HTH, Rob. On Tue, 2003-08-12 at 10:18, Kris Reid wrote: I'm having trouble explaining this so please bare with me. Say there is a form hosted on server A on a web page Something simple like form action=submit.php method=post onSubmit=window.onunload=null; input name=data size=25 value= //td input type=submit value=submit / /form I have the data on server B in a mysql database that needs to be inserted via that form. I have written a script that will grab one record and submit it via the form. The only problem is I have to keep going back and refreshing my web page to get it to submit another record. Is there a way of doing this? Please note I have no access to Server A so I can't just edit there database. Does this make sense? :) Thanks Kris -- .-. | Worlds of Carnage - http://www.wocmud.org | :-: | Come visit a world of myth and legend where | | fantastical creatures come to life and the | | stuff of nightmares grasp for your soul.| `-' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Robert Thanks for explaining my situation better. That's spot on. I have php grabbing data from my database and filling the form. Then JavaScript automatically submits the form. However once the form is submitted. Server A forwards the browser else where. So I have to type in my URL again. Is there some way I can more or less dump my database into theirs via the form. There are a #$%^ load of records. Thanks Kris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms
As I mentioned already you would be best not using Javascript and performing the submission via PHP. I wrote the following snippet in the past to do something similar to what you are asking. Study it and see if you can adapt it to your own needs. You should be able to loop on the form submission but you may want to disable script time limit if you expect that this will take a while. function submitForm( $host, $path, $data ) { $headerString = 'POST '.$path.' HTTP/1.0' .\r\n .'User-Agent: Lynx ;)' .\r\n .'Host: '.$host .\r\n .'Accept: */*' .\r\n .'Content-type: application/x-www-form-urlencoded' .\r\n .'Content-length: '; $postData = ''; foreach( $data as $key = $value ) { $postData .= urlencode( $key ).'='.urlencode( $value ).''; } $postData = ereg_replace( '.$', '', $postData ); $headerString .= ''.strlen( $postData ).\r\n\r\n; $headerString .= $postData.\r\n; $content = sendRequest( $host, $headerString ); $content = implode( \n, $content ); echo 'CONTENT'.\n\n.$content.\n\n; } function sendRequest( $host, $header ) { $fp = fsockopen ( $host, 80, $errno, $errstr, 30 ); $data = ''; if( !$fp ) { echo Error: $errstr ($errno)\n; } else { fputs( $fp, $header ); while( !feof( $fp ) ) { $data .= fgets( $fp, 128 ); } fclose( $fp ); } return explode( \n, $data ); } Cheers, Rob. On Tue, 2003-08-12 at 20:45, Kris Reid wrote: - Original Message - From: Robert Cummings [EMAIL PROTECTED] If I understand your question correctly it sounds like you want to populate a database on Server A with data residing in a database on server B via a form hosted on server A *grin*. Obviously this is tedious, and if there are a lot of entries then I would suggest writing a script to populate and submit the form automatically. If you are lucky everything will be done via HTML GET method (URL parameters); however, it is more likely that it uses the POST method. You can do some reading into posting data via HTML request headers, or you can look and see if there is a class that does what you want in PEAR or PHP Classes. HTH, Rob. Robert Thanks for explaining my situation better. That's spot on. I have php grabbing data from my database and filling the form. Then JavaScript automatically submits the form. However once the form is submitted. Server A forwards the browser else where. So I have to type in my URL again. Is there some way I can more or less dump my database into theirs via the form. There are a #$%^ load of records. Thanks Kris -- .-. | Worlds of Carnage - http://www.wocmud.org | :-: | Come visit a world of myth and legend where | | fantastical creatures come to life and the | | stuff of nightmares grasp for your soul.| `-' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP
On Sunday 20 July 2003 12:37, Jason Giangrande wrote: I have a question about forms and PHP. Here's what I'm looking to do. I'm trying to set up a spell checker that checks text entered in a form, but I want the check results to show up in a different window so that the user can change the misspelled words if they'd like. In other words, I want to be able to click a link and have another page open that checks the spelling. My question is how can I send the text from the form to this other page (which, right now, is a separate php script) so it can be spell checked without actually submitting the actual form first? In other words, I would like the user to be able to check the spelling without actually submitting the form. Squirrelmail has a nice spelling checker which works similar to that. Take a look to see if you can borrow some ideas/code. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* It is not a good omen when goldfish commit suicide. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP
Yasir Malik wrote: I'm working with forms using PHP and HTML. I've noticed that there is a limit of the length of a URL that can sent to browser (I'm passing many many things as arguments across pages). Is there a way to get across the limit or am I doing something wrong? Yasir Submit your form via post instead of get. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP
* Thus wrote Yasir Malik ([EMAIL PROTECTED]): I'm working with forms using PHP and HTML. I've noticed that there is a limit of the length of a URL that can sent to browser (I'm passing many many things as arguments across pages). Is there a way to get across the limit or am I doing something wrong? Yasir using a form POST has virtually unlimited amount data that can be sent. if you have to keep passing the data around, I would suggest to storing the data in a session of some sort then just passing the session variable around in the urls. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and PHP
Not sure why you don't want to submit the form. But if you really really don't want to submit the form then you have to use javascript. If you're willing to submit the form, then this is relatively simple, depending on how you want to display the data. if you're willing to submit, then step through the field that has the data, one word at a time (maybe explode the string on (space)) and compare the word to your dictionary. if the word is misspelled, then add it to an array, or do some action -Original Message- From: Jason Giangrande [mailto:[EMAIL PROTECTED] Sent: Saturday, July 19, 2003 8:37 PM To: [EMAIL PROTECTED] Subject: [PHP] Forms and PHP I have a question about forms and PHP. Here's what I'm looking to do. I'm trying to set up a spell checker that checks text entered in a form, but I want the check results to show up in a different window so that the user can change the misspelled words if they'd like. In other words, I want to be able to click a link and have another page open that checks the spelling. My question is how can I send the text from the form to this other page (which, right now, is a separate php script) so it can be spell checked without actually submitting the actual form first? In other words, I would like the user to be able to check the spelling without actually submitting the form. Thanks, Jason Giangrande -- 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] Forms and PHP
This is done with javascript... without getting too off topic... JS can get the contents of the textarea, and submit it via get (maybe post as well) to another (pop-up) window. the pop-up window can highlght misspelled words, and even make dynamic changes to the content in the first window. it's pretty complex stuff though... and definitely NOT for the JS newbie... look around the JS lists and sites for something that might give you a head start. justin On Sunday, July 20, 2003, at 02:37 PM, Jason Giangrande wrote: I have a question about forms and PHP. Here's what I'm looking to do. I'm trying to set up a spell checker that checks text entered in a form, but I want the check results to show up in a different window so that the user can change the misspelled words if they'd like. In other words, I want to be able to click a link and have another page open that checks the spelling. My question is how can I send the text from the form to this other page (which, right now, is a separate php script) so it can be spell checked without actually submitting the actual form first? In other words, I would like the user to be able to check the spelling without actually submitting the form. Thanks, Jason Giangrande -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- [This E-mail scanned for viruses] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP
* Thus wrote Justin French ([EMAIL PROTECTED]): This is done with javascript... without getting too off topic... JS can get the contents of the textarea, and submit it via get (maybe post as well) to another (pop-up) window. the pop-up window can highlght misspelled words, and even make dynamic changes to the content in the first window. Yes you can do a POST with javascript :) Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP
Thanks guys. I think I'll try it first as Chris suggested and see how that goes. Thanks again. Jason On Sun, 2003-07-20 at 00:55, Justin French wrote: This is done with javascript... without getting too off topic... JS can get the contents of the textarea, and submit it via get (maybe post as well) to another (pop-up) window. the pop-up window can highlght misspelled words, and even make dynamic changes to the content in the first window. it's pretty complex stuff though... and definitely NOT for the JS newbie... look around the JS lists and sites for something that might give you a head start. justin On Sunday, July 20, 2003, at 02:37 PM, Jason Giangrande wrote: I have a question about forms and PHP. Here's what I'm looking to do. I'm trying to set up a spell checker that checks text entered in a form, but I want the check results to show up in a different window so that the user can change the misspelled words if they'd like. In other words, I want to be able to click a link and have another page open that checks the spelling. My question is how can I send the text from the form to this other page (which, right now, is a separate php script) so it can be spell checked without actually submitting the actual form first? In other words, I would like the user to be able to check the spelling without actually submitting the form. Thanks, Jason Giangrande -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- [This E-mail scanned for viruses] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP_SELF
For print $PHP_SELF, or $_SERVER['PHP_SELF'] use: ?php echo $_SERVER['PHP_SELF']; ? or the shortcur sintax: ?=$_SERVER['PHP_SELF']? (if short_open_tag = On in php.ini) - Original Message - From: Beauford.2005 [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Sunday, July 06, 2003 1:43 AM Subject: [PHP] Forms and PHP_SELF Hi, I have a very simple form that searches a MySQL database and I want to be able to have the search appear on the same page as the search. FORM NAME=search METHOD=post ACTION=? $PHP_SELF; ? INPUT type=text size=30 name=player INPUT TYPE=image src=../images/submit.gif width=75 height30 value=submit /FORM The part that confuses me is how I run the code for the search. Currently I have it in a function and at the top of the script I have an IF statement that checks to see if the submit button has been pressed, if it has I go to the function. This is not working, and I'm not even sure this is the right way to go about it. I'm probably doing this wrong and would appreciate it if someone could set me straight. -- 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] Forms and PHP_SELF
Dan Anderson wrote: Be careful when using PHP self. Not all servers support it. If you're planning on using this script over and over on multiple servers you may find creating a variable is helpful. $some_variable = the_script_name.php; Then, where you would use PHP_SELF just echo (or whatever) $some_variable. You will have to change it if the script name changes, but otherwise it's just a relative path. Please don't mislead users! That's plain untrue. You're correct that not all servers have register_globals on, so use $HTTP_SERVER_VARS['PHP_SELF']. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP_SELF
Please don't mislead users! That's plain untrue. I assure you that server administrators can turn off the variables such as PHP SELF. It may not be common but it does happen. -Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP_SELF
Dan Anderson wrote: I assure you that server administrators can turn off the variables such as PHP SELF. It may not be common but it does happen. The only way to do that would be editing the PHP source. That's above the IQ of any sysadmin who would want to do that. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms PHP
On Wed, 02 Jul 2003 14:58:39 +0100, Greg Wiley [EMAIL PROTECTED] wrote: On Wed, 2 Jul 2003 14:45:27 +0100, Gary Ogilvie [EMAIL PROTECTED] wrote: [snip] By maintaining the POST (assuming you're using POST)variables and calling them into the form values when reloaded. If you go to the second page store the POST variables in hidden form input types, then grab them when the second page is POSTED. Does this make sense? Not enough caffeine for me yet...[/snip] So basically I need to have 2 versions of the first page, is that right? :) No, in your first form you have code like Well almost. I realised whilst trying to get to sleep last night that there's a problem with this. In the first form you need: ?php if ((!isset($_POST)) || (!isset($_POST['foo']))) { $foo = set default value here; $action = form2.php; } else { $foo = $_POST['foo']; $action = results.php; } ? form method=post action=?php echo $action;? input type=text name=foo value=?php echo $foo;? / ... /form This way you won't get a circular dependency. However, it means that you'll need to provide some other way of amending the details on form2 if it's a requirement. and in the second form you have: form method=post action=form1.php input type=hidden name=foo value=?php echo $_POST['foo'];? / ... /form Cheers, Greg. -- Greg Wiley www.wileysworld.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms PHP
[snip] I have a form that gets filled out and within this form there is a link to add additional information in a new form. When this information is saved I would like the browser to redirect to the previous form (this I can do) but with all the details they have already filled out still in the text boxes. What is the easiest way to do this using PHP? [/snip] By maintaining the POST (assuming you're using POST)variables and calling them into the form values when reloaded. If you go to the second page store the POST variables in hidden form input types, then grab them when the second page is POSTED. Does this make sense? Not enough caffeine for me yet... Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms PHP
[snip] By maintaining the POST (assuming you're using POST)variables and calling them into the form values when reloaded. If you go to the second page store the POST variables in hidden form input types, then grab them when the second page is POSTED. Does this make sense? Not enough caffeine for me yet...[/snip] So basically I need to have 2 versions of the first page, is that right? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms PHP
[snip] By maintaining the POST (assuming you're using POST)variables and calling them into the form values when reloaded. If you go to the second page store the POST variables in hidden form input types, then grab them when the second page is POSTED. Does this make sense? Not enough caffeine for me yet...[/snip] So basically I need to have 2 versions of the first page, is that right? :) [/snip] Not really, test for emptiness of the variable (isset())...if it is set display it, if not show it as blank. HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms PHP[Scanned]
If I've understood your initial email correctly another approach would be to save the contents of the form to your database and populate the form fields presented subsequently with information retrieved from the database. You can use the header function to redirect to whatever page you wish once the information has been saved. Regards, Michael Egan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms PHP
[snip] Not really, test for emptiness of the variable (isset())...if it is set display it, if not show it as blank. HTH! Jay [/snip] You'll have to forgive me as I am unfamiliar with PHP, still a beginner!! So if I have a page (page1.php) which is my first page with a form. When I click a normal link within this form it takes me to page2.php. This page has another smaller form. When the submit button in this form is clicked it updates the database with no problems and displays a link - linking back to page1.php (I have decided not to use redirect). How do load the page and fill all the text boxes with the information that was already written - because this information (from page1.php, first form) has not been saved to the database yet. You probably knew this anyway - but I had to go through that process to satisfy myself!! Many Thanks Gary Ogilvie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php