RE: [PHP] Re: php form action breaks script
-Original Message- From: Tim Dunphy [mailto:bluethu...@gmail.com] Sent: 28 June 2012 01:18 Hey guys, It's been a little while since I've toyed with this, and I hope you don't mind my coming back to you for some more advice. But I've enjoyed some limited success with David R's advice regarding adding some strong quoting to the mix. Here is what I last tried - form method=post action=' . $_SERVER['[PHP_SELF'] .' Wow! That's completely wacko! (OK, just looked at the full code and seen it's in the middle of a single-quoted echo, so it's not that bad after all :). You've got a spare [ in there -- the notice saying Undefined index: [PHP_SELF should have alerted you to this, as the index you want is just plain PHP_SELF. form method=post action=' . $_SERVER['PHP_SELF'] .' The pages do work, and the form checking code does its job (empty text displays what information is missing). Except that there is an annoying message that appears on screen and in the logs - Notice: Undefined index: subject in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendema il.php on line 23 Notice: Undefined index: elvismail in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendema il.php on line 24 Notice: Undefined index: [PHP_SELF in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendema il.php on line 62 Looking at the relevant bit of your script (assume this is line 23 onward): $subject = $_POST['subject']; $text = $_POST['elvismail']; $output_form = false; if (isset($_POST['Submit'])) { You're accessing $_POST['subject'] and $_POST['elvismail'] *before* the check to see if this is a from a form submission - on the initial access, to just display the form, these $_POST indexes will not be set so causing the notices. You either need to put the assignments inside the if (isset($POST['Submit'])) branch, or conditionalise them in some way, such as: $subject = isset($_POST['subject']) ? $_POST['subject'] : NULL; $text = isset($_POST['elvismail']) ? $_POST['elvismail'] : NULL; Another oddity in your script is that you're using the string values true and false instead of the Boolean true and false. Because of the way PHP typecasts, both true and false are actually regarded as Boolean true, which could get a little confusing -- so it's much better (and probably more efficient) to use the proper Boolean values. Also, it enables your later test to be written, with confidence, as just if ($output_form) { Also, also, with a little bit of rearrangement of the tests, you can reduce the amount of code a bit: if (!empty($subject) !empty($text)) { // Both inputs supplied -- good to go. $output_form = false; } else { // At least one input missing -- need to redisplay form $output_form = true; if (empty($subject)) { if (empty($text)) { echo 'You forgot the email subject and body.br /'; } else { echo 'You forgot the email subject.br /'; } } else { echo 'You forgot the email body text.br /'; } } Actually, I think my inclination would be to assign $output_form first, and then do the rest of the tests: $output_form = empty($subject) || empty($text); if ($output_form) { // At least one input missing -- work out which one if (empty($subject)) if (empty($text)) { echo 'You forgot the email subject and body.br /'; } else { echo 'You forgot the email subject.br /'; } } else { echo 'You forgot the email body text.br /'; } } That said, there are lots of personal preferences involved here, and I'm sure others would offer different possibilities. (Me personally, I also prefer the alternative block syntax with initial : and end... tags -- but then, the forests of curly braces others seem to find acceptable make my eyes go fuzzy, so go figure) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
On Thu, Jun 28, 2012 at 2:17 AM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, It's been a little while since I've toyed with this, and I hope you don't mind my coming back to you for some more advice. But I've enjoyed some limited success with David R's advice regarding adding some strong quoting to the mix. Here is what I last tried - Please bottom post on this (and probably any) mailing list. form method=post action=' . $_SERVER['[PHP_SELF'] .' This must be some typo, it should read form method=post action=' . $_SERVER['PHP_SELF'] .' $from = 'bluethu...@jokefire.com'; $subject = $_POST['subject']; $text = $_POST['elvismail']; $output_form = false; Try using $subject = isset($_POST['subject']) ? $_POST['subject'] : ; $subject = isset($_POST['elvismail']) ? $_POST['elvismail'] : ; Cheers, Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
On Wed, Jun 27, 2012 at 7:17 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, It's been a little while since I've toyed with this, and I hope you don't mind my coming back to you for some more advice. But I've enjoyed some limited success with David R's advice regarding adding some strong quoting to the mix. Here is what I last tried - form method=post action=' . $_SERVER['[PHP_SELF'] .' Just a wee typo here: You've quoted '[PHP_SELF' -- the extra bracket at the beginning what's wrong there. Should just be 'PHP_SELF'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
On Wed, Jun 27, 2012 at 7:17 PM, Tim Dunphy bluethu...@gmail.com wrote: One more little thing: These notices: Notice: Undefined index: subject in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 23 Notice: Undefined index: elvismail in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php show up because you are processing form fields in $_POST when there might not be any yet. These lines: $from = 'bluethu...@jokefire.com'; $subject = $_POST['subject']; $text = $_POST['elvismail']; $output_form = false; Should appear *after* this line: if (isset($_POST['Submit'])) { You should also check the $_POST entries for 'subject' and 'elvismail' to make sure they are set to avoid the notices, even if you do move them after the submit check. You never know! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
Tim Dunphy bluethu...@gmail.com wrote in message news:caozy0em5duhby-qv+y1u-e+c5yd7g5utauhomoyu3z7jma-...@mail.gmail.com... Notice: Undefined index: subject in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 23 Notice: Undefined index: elvismail in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 24 Notice: Undefined index: [PHP_SELF in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 62 [Wed Jun 27 20:13:42 2012] [error] [client 127.0.0.1] PHP Notice: Undefined index: [PHP_SELF in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 62, referer: http://localhost/elvis/ You're missing an input (POST) for the field named 'subject'. Something change in your html? As in you no longer have a 'subject' input field? Same for the other field named. As for the missing PHP_SELF - did you start a session? I could be way off on this. The errors are even giving you the line number so it shouldn't be hard to find! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php form action breaks script
On 6/14/2012 7:28 PM, Tim Dunphy wrote: Hello list, I was just wondering if I could get some opinions on a snippet of code which breaks a php web page. First the working code which is basically an html form being echoed by php: if ($output_form) { echo 'br /br /form action=sendemail.php method=post label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text size=30 /br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40/textareabr / input type=submit name=Submit value=Submit / /form'; } However if I change the form action to this, it breaks the page resulting in a white screen of death: if ($output_form) { echo 'br /br /form action=?php echo $_SERVER['PHP_SELF']; ? method=post label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text size=30 /br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40/textareabr / input type=submit name=Submit value=Submit / /form'; } Reverting the one line to this: echo 'br /br /form action=sendemail.php method=post gets it working again. Now I don't know if it's an unbalanced quote mark or what's going on. But I'd appreciate any advice you may have. Best, tim heredoc is best for this if ($output_form){ $report = sty br /br / form action=sendemail.php method=post label for=subjectSubject of email:/label br / input id=subject name=subject type=text size=30 / br / label for=elvismailBody of email:/label br / textarea id=elvismail name=elvismail rows=8cols=40/textarea br / input type=submit name=Submit value=Submit / /form sty; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
Al n...@ridersite.org hat am 15. Juni 2012 um 14:29 geschrieben: On 6/14/2012 7:28 PM, Tim Dunphy wrote: However if I change the form action to this, it breaks the page resulting in a white screen of death: error_reporting(E_ALL); ini_set('display_errors', 'On'); And what is the error message? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php form action breaks script
Hear, Hear for heredocs. The only way to code up your html. Took me a few months to discover it and haven't looked back since. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
On 06/15/2012 06:35 AM, Jim Giner wrote: Hear, Hear for heredocs. The only way to code up your html. Took me a few months to discover it and haven't looked back since. The only problem I have with HEREDOC is I cannot use constants within them. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
Jim Lucas li...@cmsws.com hat am 15. Juni 2012 um 18:39 geschrieben: On 06/15/2012 06:35 AM, Jim Giner wrote: Hear, Hear for heredocs. The only way to code up your html. Took me a few months to discover it and haven't looked back since. The only problem I have with HEREDOC is I cannot use constants within them. You shouldn't use constants anyway. Always inject your dependencies. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
It is a small price to pay for large block, especially if the text has any quotes. Personally, I can't keep them straight and delimit them, etc. Heredoc saves all that such stuff. $insert= MY_DEFINED; echo hdc This is my $insert hdc; On 6/15/2012 12:39 PM, Jim Lucas wrote: On 06/15/2012 06:35 AM, Jim Giner wrote: Hear, Hear for heredocs. The only way to code up your html. Took me a few months to discover it and haven't looked back since. The only problem I have with HEREDOC is I cannot use constants within them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php form action breaks script
Tim Dunphy wrote: Hello list, I was just wondering if I could get some opinions on a snippet of code which breaks a php web page. First the working code which is basically an html form being echoed by php: if ($output_form) { echo 'br /br /form action=sendemail.php method=post label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text size=30 /br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40/textareabr / input type=submit name=Submit value=Submit / /form'; } However if I change the form action to this, it breaks the page resulting in a white screen of death: if ($output_form) { echo 'br /br /form action=?php echo $_SERVER['PHP_SELF']; ? method=post label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text size=30 /br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40/textareabr / input type=submit name=Submit value=Submit / /form'; } Reverting the one line to this: echo 'br /br /form action=sendemail.php method=post gets it working again. Now I don't know if it's an unbalanced quote mark or what's going on. But I'd appreciate any advice you may have. Best, tim If you check your apache log you'll probably see an error message. But the problem seems to be that your string you are trying to echo is enclosed in single quotes, and contains a string in ?php tags. Try something like echo 'br /br /form action=' . $_SERVER['PHP_SELF'] . ' method=post ...etc Cheers -- David Robley I haven't had any tooth decay yet, said Tom precariously. Today is Sweetmorn, the 20th day of Confusion in the YOLD 3178. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
On Thu, Jun 14, 2012 at 10:17 PM, David Robley robl...@aapt.net.au wrote: Tim Dunphy wrote: Hello list, I was just wondering if I could get some opinions on a snippet of code which breaks a php web page. First the working code which is basically an html form being echoed by php: if ($output_form) { echo 'br /br /form action=sendemail.php method=post form action=sendemail.php should be: form action=sendemail.php ... label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text size=30 /br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40/textareabr / input type=submit name=Submit value=Submit / /form'; } However if I change the form action to this, it breaks the page resulting in a white screen of death: if ($output_form) { echo 'br /br /form action=?php echo $_SERVER['PHP_SELF']; ? method=post label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text size=30 /br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40/textareabr / input type=submit name=Submit value=Submit / /form'; } Reverting the one line to this: echo 'br /br /form action=sendemail.php method=post gets it working again. Now I don't know if it's an unbalanced quote mark or what's going on. But I'd appreciate any advice you may have. Best, tim If you check your apache log you'll probably see an error message. But the problem seems to be that your string you are trying to echo is enclosed in single quotes, and contains a string in ?php tags. Try something like echo 'br /br /form action=' . $_SERVER['PHP_SELF'] . ' method=post ...etc Cheers -- David Robley I haven't had any tooth decay yet, said Tom precariously. Today is Sweetmorn, the 20th day of Confusion in the YOLD 3178. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Paul Halliday http://www.squertproject.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Feb 14, 2012, at 1:39 PM, Daniel Brown wrote: On Tue, Feb 14, 2012 at 13:36, Rick Dwyer rpdw...@earthlink.net wrote: I only have access to domain B... the one receiving the Form POST. Then all you should need to do is: a.) Verify that Domain A is indeed pointing to Domain B, to the script you expect, as a POST request. b.) In the POST-receiving script on Domain B, try this simple snippet: ?php echo 'pre'.PHP_EOL; var_dump($_POST); die('/pre'); ? That should give you all data from the post request. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ Why the '.PHP_EOL' ? I've never seen that before and looking through the PHP documentation doesn't give me much. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Thu, Feb 16, 2012 at 09:53, Tedd Sperling tedd.sperl...@gmail.com wrote: Why the '.PHP_EOL' ? I've never seen that before and looking through the PHP documentation doesn't give me much. Cross-compatibility. For systems which use \n, PHP_EOL will be \n. For systems which use \r\n, PHP_EOL will be \r\n. And, for oddball or legacy systems which still use \r you get the point. This means you can rest assured that the newlines will be appropriate for the system on which PHP is running. While it makes little difference on the web, it makes a world of difference at the CLI and when writing to plain-text files (including CSV). I've been using it out of the force of habit for about seven years or so, and exclusively (with the exception of email headers and other warranted cases) for the last four. There are a lot of other very useful and yet very underused constants. You can find the info on them here: http://php.net/reserved.constants -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Thu, Feb 16, 2012 at 4:09 PM, Daniel Brown danbr...@php.net wrote: On Thu, Feb 16, 2012 at 09:53, Tedd Sperling tedd.sperl...@gmail.com wrote: This means you can rest assured that the newlines will be appropriate for the system on which PHP is running. While it makes little difference on the web, it makes a world of difference at the CLI and when writing to plain-text files (including CSV). I've been using it out of the force of habit for about seven years or so, and exclusively (with the exception of email headers and other warranted cases) for the last four. What if the system PHP is running on not the same one as the one that is going to read the plain-text/CSV/.. files? I don't think it is good practice to use it when writing to files. I often write files on a Linux server that people are going to read on a Windows PC. Apart from that, most software written in the last 5-10 years will happily read files with either \n or \r\n line endings. I'm not really sure about Win XP for example, but if it would have a problem with the Linux \n endings, it might even be better to *always* use \r\n line endings (except where standards require it), as I haven't seen a single Linux application since I started using it (about 9 years ago) that was not able to read a file with \r\n based line endings. Even better, go Unicode. Unicode specifies that there are 8 ways to make a new line, and they should all be accepted. However, the pretty uncommon NEL, LS and PS are not supported in many applications. (though CR, LF and CRLF are). - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Thu, Feb 16, 2012 at 10:57, Matijn Woudt tijn...@gmail.com wrote: What if the system PHP is running on not the same one as the one that is going to read the plain-text/CSV/.. files? I don't think it is good practice to use it when writing to files. I often write files on a Linux server that people are going to read on a Windows PC. Then what is the difference between PHP_EOL and forcing \n? It's still going to use POSIX-style EOLs, but now you've taken away the benefit of the compatibility. Apart from that, most software written in the last 5-10 years will happily read files with either \n or \r\n line endings. I'm not really sure about Win XP for example, but if it would have a problem with the Linux \n endings, it might even be better to *always* use \r\n line endings (except where standards require it), as I haven't seen a single Linux application since I started using it (about 9 years ago) that was not able to read a file with \r\n based line endings. You may want to check again. Ever see ^M at the end of your lines? Or, in vim, notice how it says it's a DOS file? Even better, go Unicode. Unicode specifies that there are 8 ways to make a new line, and they should all be accepted. However, the pretty uncommon NEL, LS and PS are not supported in many applications. (though CR, LF and CRLF are). Nothing you've suggested is necessarily bad, but more to the point, it doesn't come close to invalidating the benefit of PHP_EOL. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Thu, Feb 16, 2012 at 5:02 PM, Daniel Brown danbr...@php.net wrote: On Thu, Feb 16, 2012 at 10:57, Matijn Woudt tijn...@gmail.com wrote: What if the system PHP is running on not the same one as the one that is going to read the plain-text/CSV/.. files? I don't think it is good practice to use it when writing to files. I often write files on a Linux server that people are going to read on a Windows PC. Then what is the difference between PHP_EOL and forcing \n? It's still going to use POSIX-style EOLs, but now you've taken away the benefit of the compatibility. I'm not saying you should force \n then, but you might want to decide what to force depending on who will be using it, so in case a windows user is going to read it, then you set \r\n, otherwise you select \n.You could even try to detect that based on a browser identification string. Apart from that, most software written in the last 5-10 years will happily read files with either \n or \r\n line endings. I'm not really sure about Win XP for example, but if it would have a problem with the Linux \n endings, it might even be better to *always* use \r\n line endings (except where standards require it), as I haven't seen a single Linux application since I started using it (about 9 years ago) that was not able to read a file with \r\n based line endings. You may want to check again. Ever see ^M at the end of your lines? Or, in vim, notice how it says it's a DOS file? I have seen them, but only in files which had mixed line endings, which should of course never be used. Vim does indeed notice it's a 'dos' file, but it's merely detecting that the file has \r\n line endings and that it should add those too. I don't consider that bad. Even better, go Unicode. Unicode specifies that there are 8 ways to make a new line, and they should all be accepted. However, the pretty uncommon NEL, LS and PS are not supported in many applications. (though CR, LF and CRLF are). Nothing you've suggested is necessarily bad, but more to the point, it doesn't come close to invalidating the benefit of PHP_EOL. I'm not saying using PHP_EOL is bad, but I disagree with using it always as a habit. If line endings matter, then you need to make decisions based on that, and don't depend on it being automatically OK if PHP_EOL is used. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form Post to different domain
Hello all. If I have a form on domain A that uses POST to submit data and I want to submit the form to domain B on an entirely different server, how do I pull the form values (... echo $_POST[myval] returns nothing) from the form at domain B? --Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Tue, Feb 14, 2012 at 13:14, Rick Dwyer rpdw...@earthlink.net wrote: Hello all. If I have a form on domain A that uses POST to submit data and I want to submit the form to domain B on an entirely different server, how do I pull the form values (... echo $_POST[myval] returns nothing) from the form at domain B? First (basic, obvious) question: do you have full access to both domains, or is Domain B a third-party site? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Feb 14, 2012, at 1:16 PM, Daniel Brown wrote: On Tue, Feb 14, 2012 at 13:14, Rick Dwyer rpdw...@earthlink.net wrote: Hello all. If I have a form on domain A that uses POST to submit data and I want to submit the form to domain B on an entirely different server, how do I pull the form values (... echo $_POST[myval] returns nothing) from the form at domain B? First (basic, obvious) question: do you have full access to both domains, or is Domain B a third-party site? I only have access to domain B... the one receiving the Form POST. --Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
On Tue, Feb 14, 2012 at 13:36, Rick Dwyer rpdw...@earthlink.net wrote: I only have access to domain B... the one receiving the Form POST. Then all you should need to do is: a.) Verify that Domain A is indeed pointing to Domain B, to the script you expect, as a POST request. b.) In the POST-receiving script on Domain B, try this simple snippet: ?php echo 'pre'.PHP_EOL; var_dump($_POST); die('/pre'); ? That should give you all data from the post request. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Post to different domain
Thanks Dan. As it turned out the reason for not showing the passed values is that I didn't have www in the destination address and the values must have been getting lost when Apache redirected requests without www to the fully formed URL. --Rick On Feb 14, 2012, at 1:39 PM, Daniel Brown wrote: On Tue, Feb 14, 2012 at 13:36, Rick Dwyer rpdw...@earthlink.net wrote: I only have access to domain B... the one receiving the Form POST. Then all you should need to do is: a.) Verify that Domain A is indeed pointing to Domain B, to the script you expect, as a POST request. b.) In the POST-receiving script on Domain B, try this simple snippet: ?php echo 'pre'.PHP_EOL; var_dump($_POST); die('/pre'); ? That should give you all data from the post request. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form validation
-Original Message- From: paras...@gmail.com [mailto:paras...@gmail.com] On Behalf Of Daniel P. Brown Sent: 12 August 2011 16:53 On Fri, Aug 12, 2011 at 11:42, Chris Stinemetz chrisstinem...@gmail.com wrote: I have a select menu created by a foreach loop. I am trying to validate that there was a selection made before it is submitted to the database. But I am not doing something correctly. Try using a combination of isset, empty, and is_null() instead: ?php if (!isset($_POST['market']) || empty($_POST['market']) || is_null($_POST['market'])) { // Wasn't set } ? The last part of that test is redundant, since if $_POST['market'] is NULL isset($_POST['market'] will be FALSE. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation
On Sun, Aug 14, 2011 at 18:19, Ford, Mike m.f...@leedsmet.ac.uk wrote: The last part of that test is redundant, since if $_POST['market'] is NULL isset($_POST['market'] will be FALSE. Good catch. Didn't even notice I typed that. Not that it would've done any damage, but a good reminder why code here is not meant to be blindly copied-and-pasted. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
Chris Stinemetz chrisstinem...@gmail.com wrote: I would bet it's the quotes screwing up the js. Can / are you escaping that variable when ajaxing it back? Bastien Koert 905-904-0334 I found a way to make the ajax work with one form. I removed the table and the ajax worked just fine. Aparently you can't embed div containers within a table without affecting the whole table. At least that is what I found out tonight. Please correct me if I am wrong. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Without seeing your code, its hard to figure out what is happening. Post it onto pastebin or something (large code excerpts are very hard to read on this mailing list). Often, running the code through validator.w3.org will find issues that are affecting your layout. Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
it's (pretty) easy to send two forms at once with jquery nowadays, you just get all the input of the 2 forms and post them! function submit2Forms(form1DomId,form2DomId){ $datas={}; $(form1DomId).find(':input').each(function(){ if(($(this).attr('name') $(this).attr('type')!='checkbox') || ($(this).attr('type')=='checkbox' $(this).is(':checked'))) $datas[$(this).attr('name')]=$(this).val(); }); $(form2DomId).find(':input').each(function(){ if(($(this).attr('name') $(this).attr('type')!='checkbox') || ($(this).attr('type')=='checkbox' $(this).is(':checked'))) $datas[$(this).attr('name')]=$(this).val(); }); $.post(URL,function(html) { $('body').html(html); }) return false; }); it's just a small example so you can see how you can do it! On 12 August 2011 08:48, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Chris Stinemetz chrisstinem...@gmail.com wrote: I would bet it's the quotes screwing up the js. Can / are you escaping that variable when ajaxing it back? Bastien Koert 905-904-0334 I found a way to make the ajax work with one form. I removed the table and the ajax worked just fine. Aparently you can't embed div containers within a table without affecting the whole table. At least that is what I found out tonight. Please correct me if I am wrong. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Without seeing your code, its hard to figure out what is happening. Post it onto pastebin or something (large code excerpts are very hard to read on this mailing list). Often, running the code through validator.w3.org will find issues that are affecting your layout. Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form validation
I have a select menu created by a foreach loop. I am trying to validate that there was a selection made before it is submitted to the database. But I am not doing something correctly. select name=market class=ajax onchange=javascript:get(this.parentNode); option value=Choose.../option ?php foreach($market_prefix as $key = $value) { $selected = ''; if($value == $market) { $selected = 'selected'; } echo 'option value=', htmlspecialchars($value), ' ', $selected, '', htmlspecialchars($market_name[$key]), '/option'; } ? /select I am using the folling on the posted page. if (! array_key_exists($_POST['market'], $market_name)) { echo You did not select a market.; } Thank you, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation
On Fri, Aug 12, 2011 at 11:42, Chris Stinemetz chrisstinem...@gmail.com wrote: I have a select menu created by a foreach loop. I am trying to validate that there was a selection made before it is submitted to the database. But I am not doing something correctly. Try using a combination of isset, empty, and is_null() instead: ?php if (!isset($_POST['market']) || empty($_POST['market']) || is_null($_POST['market'])) { // Wasn't set } ? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation
On 12 August 2011 16:42, Chris Stinemetz chrisstinem...@gmail.com wrote: I have a select menu created by a foreach loop. I am trying to validate that there was a selection made before it is submitted to the database. But I am not doing something correctly. select name=market class=ajax onchange=javascript:get(this.parentNode); option value=Choose.../option ?php foreach($market_prefix as $key = $value) { $selected = ''; if($value == $market) { $selected = 'selected'; } echo 'option value=', htmlspecialchars($value), ' ', $selected, '', htmlspecialchars($market_name[$key]), '/option'; } ? /select I am using the folling on the posted page. if (! array_key_exists($_POST['market'], $market_name)) { echo You did not select a market.; } Thank you, Chris $_POST['market'] won't exist if you haven't chosen one. Turn on your error reporting and you should see something appropriate. At a bare minimum, adding ... isset($_POST['market']) as the first thing to test (before seeing if the value is in $market_name (though I would have thought $market_names would have been a better name for the variable - implies more than 1 market). -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form handling
I have two forms on the same php script. Is it possible to submit both forms to the same action=processform.php with a single submit button? If so would you give me examples on how to handle this? I will also continue searching google. Thank you, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
On 11 Aug 2011, at 19:25, Chris Stinemetz wrote: I have two forms on the same php script. Is it possible to submit both forms to the same action=processform.php with a single submit button? If so would you give me examples on how to handle this? Three options spring to mind... 1) Combine them into one form in the HTML. 2) Run some JS on submit that combines the values into one form and submits that. 3) Use AJAX to submit the forms separately but simultaneously. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
At 02:25 PM 8/11/2011, Chris Stinemetz wrote: I have two forms on the same php script. Is it possible to submit both forms to the same action=processform.php with a single submit button? If you want to submit at the same time, why do you have two forms? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
If the two forms call the same script that's fine. If not, that will work too. Just realize that the inputs from one form will NOT be returned to the script when the submit is used from the other form. Jim, This is what I am trying to do. One submit button for both forms going to the same destination. The only reason I am doing this is because I can't figure out why my ajax for my select menus is altering my tinyMCE textarea box. Ultimately if I can figure out how to control the ajax within the div container as I showed in a previous email I would be able to just use one form. any ideas?? Thanks, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
I'm thinking that Chris means that he has a 'page' designed that utilizes two form tags for functionally different sets of input fields. The answer Chris is that a page can have many forms and whether or not they trigger the same script upon submit or not doesn't matter. Go ahead! My sample html: blah blah head script /script style /style /head body form inputs /form blah blah form inputs /form /body /html If the two forms call the same script that's fine. If not, that will work too. Just realize that the inputs from one form will NOT be returned to the script when the submit is used from the other form. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
Jim, This is what I am trying to do. One submit button for both forms going to the same destination. The only reason I am doing this is because I can't figure out why my ajax for my select menus is altering my tinyMCE textarea box. Ultimately if I can figure out how to control the ajax within the div container as I showed in a previous email I would be able to just use one form. any ideas?? Thanks, Chris Chris, By definition, a 'submit' button submits a form. Not 2 forms. Each form has to have it's own form. It is not feasible to submit two forms - since the conversation from your client pc is going to be garbled even if you could (JS?) do the second submit. One transactiion is going to answer your client and then the other is going to wipe it out with its respone. I don't think you have ot separate your forms becuase they are in separate divs. I could be wrong - never tried it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
Chris, By definition, a 'submit' button submits a form. Not 2 forms. Each form has to have it's own form. It is not feasible to submit two forms - since the conversation from your client pc is going to be garbled even if you could (JS?) do the second submit. One transactiion is going to answer your client and then the other is going to wipe it out with its respone. I don't think you have ot separate your forms becuase they are in separate divs. I could be wrong - never tried it. I didn't think it was possible either. I will play around with the div container and ajax some more tonight. Hope I will be able to figure it out. Is it possible to place a div within the form to only affect the select tags? Thanks, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
On 2011-08-11, at 9:13 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Jim, This is what I am trying to do. One submit button for both forms going to the same destination. The only reason I am doing this is because I can't figure out why my ajax for my select menus is altering my tinyMCE textarea box. Ultimately if I can figure out how to control the ajax within the div container as I showed in a previous email I would be able to just use one form. any ideas?? Thanks, Chris Chris, By definition, a 'submit' button submits a form. Not 2 forms. Each form has to have it's own form. It is not feasible to submit two forms - since the conversation from your client pc is going to be garbled even if you could (JS?) do the second submit. One transactiion is going to answer your client and then the other is going to wipe it out with its respone. I don't think you have ot separate your forms becuase they are in separate divs. I could be wrong - never tried it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I would bet it's the quotes screwing up the js. Can / are you escaping that variable when ajaxing it back? Bastien Koert 905-904-0334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
I would bet it's the quotes screwing up the js. Can / are you escaping that variable when ajaxing it back? Bastien Koert 905-904-0334 I found a way to make the ajax work with one form. I removed the table and the ajax worked just fine. Aparently you can't embed div containers within a table without affecting the whole table. At least that is what I found out tonight. Please correct me if I am wrong. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form hidden value
I'm trying to pass a hidden value with my form submission. Not sure what I am doing woring, but the value is not being passed. Query is___ $query = SELECT id, store_name FROM store_list WHERE store_type = '$type' AND id_market = '$market' ; $result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__)); while($row = mysql_fetch_array($result)) { $store_name[] = $row['store_name']; $id[] = $row['id']; } sort($store_name); } Form portion is input type=hidden name=id value=?php echo '$id[]';? Any help is greatly appreciated. Thank you.
Re: [PHP] form hidden value
On Mon, Aug 8, 2011 at 17:23, Chris Stinemetz chrisstinem...@gmail.com wrote: input type=hidden name=id value=?php echo '$id[]';? You should drop the quotes around the $id[] array, and also figure out how you want to extract the element from the array. For example: ?php echo $id[0]; ? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form hidden value
First: use firebug, or something like that, and check what's get written in the page's source! Second: dump $_POST/$_GET, and check, whether id is set at all Is your input field between the form and /form tags? Cheers, Tamas -Original Message- From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] Sent: Monday, August 08, 2011 11:23 PM To: PHP General Subject: [PHP] form hidden value I'm trying to pass a hidden value with my form submission. Not sure what I am doing woring, but the value is not being passed. Query is___ $query = SELECT id, store_name FROM store_list WHERE store_type = '$type' AND id_market = '$market' ; $result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__)); while($row = mysql_fetch_array($result)) { $store_name[] = $row['store_name']; $id[] = $row['id']; } sort($store_name); } Form portion is input type=hidden name=id value=?php echo '$id[]';? Any help is greatly appreciated. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Already Filled Out
On 08/05/2011 12:43 AM, wil prim wrote: Hello, S i created a simple login system, and I am using sessions Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance! Here is the login.php code, i didn't md5() the password yet: ?php if ($_SESSION['user']) { header(Location: error.php); exit(); } include('connect.php'); if ($_POST['login']){ $user=$_POST['user']; $pass=$_POST['pass']; $sql=SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'; $result=mysql_query($sql, $con); $count=mysql_num_rows($result); if ($count==1){ $_SESSION['user'] = $user; header('location: home.php'); } else echo p style='color:red'Wrong Username or Password/p; } ? html head title/title link href=style.css rel=stylesheet type=text/css / /head body div id=main div id=menu ul li a href=#Home/a /li li a href=#Topix/a /li li a href=#Mission/a /li /ul /div div id='content' form method='post' action='index.php' Username: br/ input type='text' name='user' maxlength='30'/br/ Password: br/ input type=password name='pass' maxlength='30'/br/ input type=submit value=Log In! name=login/ /form a href=register.html Register? /a /div /body /html Your browser is more than likely filling in the username and password fields for you, automatically. Most modern browsers offer this functionality by default. What you're looking for isn't relative to PHP. Have you tried visiting your page from multiple browsers, to see if you get the same results? You could set the value of the username and password fields in the form to NULL. e.g.; input type='text' name='user' value='' maxlength='30'/ input type=password name='pass' value='' maxlength='30'/ I doubt your visitors are going to encounter the same issue you are, unless they allow their browser or some other 3rd party software to automatically fill in the form values for them. Another method would consist of using JavaScript, once the DOM is ready (all elements rendered), have JavaScript reset the form values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Already Filled Out
Hi, Use value=$_POST['user'] or sg like that because: before send value eq null, after if returned -cause of a fail- the inputs remain also set *autocomplete=off* (at form) and if it doesn't work use js to set null values to input boxes (add a name for ur form...) Another way, use Google: javascript turn off autofill be careful: http://www.php.net/manual/en/security.database.sql-injection.php http://php.net/manual/en/security.php *Valentine* On Thu, Aug 4, 2011 at 8:54 AM, James Yerge ja...@nixsecurity.org wrote: On 08/05/2011 12:43 AM, wil prim wrote: Hello, S i created a simple login system, and I am using sessions Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance! Here is the login.php code, i didn't md5() the password yet: ?php if ($_SESSION['user']) { header(Location: error.php); exit(); } include('connect.php'); if ($_POST['login']){ $user=$_POST['user']; $pass=$_POST['pass']; $sql=SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'; $result=mysql_query($sql, $con); $count=mysql_num_rows($result); if ($count==1){ $_SESSION['user'] = $user; header('location: home.php'); } else echo p style='color:red'Wrong Username or Password/p; } ? html head title/title link href=style.css rel=stylesheet type=text/css / /head body div id=main div id=menu ul li a href=#Home/a /li li a href=#Topix/a /li li a href=#Mission/a /li /ul /div div id='content' form method='post' action='index.php' Username: br/ input type='text' name='user' maxlength='30'/br/ Password: br/ input type=password name='pass' maxlength='30'/br/ input type=submit value=Log In! name=login/ /form a href=register.html Register? /a /div /body /html Your browser is more than likely filling in the username and password fields for you, automatically. Most modern browsers offer this functionality by default. What you're looking for isn't relative to PHP. Have you tried visiting your page from multiple browsers, to see if you get the same results? You could set the value of the username and password fields in the form to NULL. e.g.; input type='text' name='user' value='' maxlength='30'/ input type=password name='pass' value='' maxlength='30'/ I doubt your visitors are going to encounter the same issue you are, unless they allow their browser or some other 3rd party software to automatically fill in the form values for them. Another method would consist of using JavaScript, once the DOM is ready (all elements rendered), have JavaScript reset the form values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Already Filled Out
if you want to force the browser to not be able to have this behaviour you need the name tag to always change a quick example would be that ?php // keep the name in session $_SESSION['formRandomName']=time(); ? input type=password name=?php echo $_SESSION['formRandomName'];?[password] / 2011/8/4 Bálint Horváth hbal...@gmail.com Hi, Use value=$_POST['user'] or sg like that because: before send value eq null, after if returned -cause of a fail- the inputs remain also set *autocomplete=off* (at form) and if it doesn't work use js to set null values to input boxes (add a name for ur form...) Another way, use Google: javascript turn off autofill be careful: http://www.php.net/manual/en/security.database.sql-injection.php http://php.net/manual/en/security.php *Valentine* On Thu, Aug 4, 2011 at 8:54 AM, James Yerge ja...@nixsecurity.org wrote: On 08/05/2011 12:43 AM, wil prim wrote: Hello, S i created a simple login system, and I am using sessions Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance! Here is the login.php code, i didn't md5() the password yet: ?php if ($_SESSION['user']) { header(Location: error.php); exit(); } include('connect.php'); if ($_POST['login']){ $user=$_POST['user']; $pass=$_POST['pass']; $sql=SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'; $result=mysql_query($sql, $con); $count=mysql_num_rows($result); if ($count==1){ $_SESSION['user'] = $user; header('location: home.php'); } else echo p style='color:red'Wrong Username or Password/p; } ? html head title/title link href=style.css rel=stylesheet type=text/css / /head body div id=main div id=menu ul li a href=#Home/a /li li a href=#Topix/a /li li a href=#Mission/a /li /ul /div div id='content' form method='post' action='index.php' Username: br/ input type='text' name='user' maxlength='30'/br/ Password: br/ input type=password name='pass' maxlength='30'/br/ input type=submit value=Log In! name=login/ /form a href=register.html Register? /a /div /body /html Your browser is more than likely filling in the username and password fields for you, automatically. Most modern browsers offer this functionality by default. What you're looking for isn't relative to PHP. Have you tried visiting your page from multiple browsers, to see if you get the same results? You could set the value of the username and password fields in the form to NULL. e.g.; input type='text' name='user' value='' maxlength='30'/ input type=password name='pass' value='' maxlength='30'/ I doubt your visitors are going to encounter the same issue you are, unless they allow their browser or some other 3rd party software to automatically fill in the form values for them. Another method would consist of using JavaScript, once the DOM is ready (all elements rendered), have JavaScript reset the form values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Already Filled Out
On Thu, 2011-08-04 at 17:02 +0100, jean-baptiste verrey wrote: if you want to force the browser to not be able to have this behaviour you need the name tag to always change a quick example would be that ?php // keep the name in session $_SESSION['formRandomName']=time(); ? input type=password name=?php echo $_SESSION['formRandomName'];?[password] / 2011/8/4 Bálint Horváth hbal...@gmail.com Hi, Use value=$_POST['user'] or sg like that because: before send value eq null, after if returned -cause of a fail- the inputs remain also set *autocomplete=off* (at form) and if it doesn't work use js to set null values to input boxes (add a name for ur form...) Another way, use Google: javascript turn off autofill be careful: http://www.php.net/manual/en/security.database.sql-injection.php http://php.net/manual/en/security.php *Valentine* On Thu, Aug 4, 2011 at 8:54 AM, James Yerge ja...@nixsecurity.org wrote: On 08/05/2011 12:43 AM, wil prim wrote: Hello, S i created a simple login system, and I am using sessions Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance! Here is the login.php code, i didn't md5() the password yet: ?php if ($_SESSION['user']) { header(Location: error.php); exit(); } include('connect.php'); if ($_POST['login']){ $user=$_POST['user']; $pass=$_POST['pass']; $sql=SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'; $result=mysql_query($sql, $con); $count=mysql_num_rows($result); if ($count==1){ $_SESSION['user'] = $user; header('location: home.php'); } else echo p style='color:red'Wrong Username or Password/p; } ? html head title/title link href=style.css rel=stylesheet type=text/css / /head body div id=main div id=menu ul li a href=#Home/a /li li a href=#Topix/a /li li a href=#Mission/a /li /ul /div div id='content' form method='post' action='index.php' Username: br/ input type='text' name='user' maxlength='30'/br/ Password: br/ input type=password name='pass' maxlength='30'/br/ input type=submit value=Log In! name=login/ /form a href=register.html Register? /a /div /body /html Your browser is more than likely filling in the username and password fields for you, automatically. Most modern browsers offer this functionality by default. What you're looking for isn't relative to PHP. Have you tried visiting your page from multiple browsers, to see if you get the same results? You could set the value of the username and password fields in the form to NULL. e.g.; input type='text' name='user' value='' maxlength='30'/ input type=password name='pass' value='' maxlength='30'/ I doubt your visitors are going to encounter the same issue you are, unless they allow their browser or some other 3rd party software to automatically fill in the form values for them. Another method would consist of using JavaScript, once the DOM is ready (all elements rendered), have JavaScript reset the form values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Please don't top-post, the gremlins don't like it :) Going back to Bálint's post, the autocomplete=off can be set either at the form or form element (input) level. Bear in mind though that if you do this, the HTML will not validate. This isn't normally an issue, and may be an acceptable tradeoff for your website. -- Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Form Already Filled Out
Hello, S i created a simple login system, and I am using sessions Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance!Here is the login.php code, i didn't md5() the password yet: ?phpif ($_SESSION['user']){ header("Location: error.php"); exit();}include('connect.php');if ($_POST['login']){ $user=$_POST['user'];$pass=$_POST['pass'];$sql="SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'";$result=mysql_query($sql, $con);$count=mysql_num_rows($result);if ($count==1){ $_SESSION['user'] = $user; header('location: home.php');}else echo "p style='color:red'Wrong Username or Password/p";}?html head title/title link href="" rel="stylesheet" type="text/css" / /head body div id="main" div id="menu" ul li a href=""Home/a /li li a href=""Topix/a /li li a href=""Mission/a /li /ul /div div id='content' form method='post' action='' Username: br/ input type='text' name='user' maxlength='30'/br/ Password: br/ input type="password" name='pass' maxlength='30'/br/ input type="submit" value="Log In!" name="login"/ /form a href="" Register? /a /div /body/html
Re: [PHP] Form Already Filled Out
Hmmm looks like you saved the password and your browser or OS may be filling it for you. Em 04/08/2011 01:42, wil prim wilp...@me.com escreveu: Hello, S i created a simple login system, and I am using sessions. Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance! Here is the login.php code, i didn't md5() the password yet: ?php if ($_SESSION['user']) { header(Location: error.php); exit(); } include('connect.php'); if ($_POST['login']){ $user=$_POST['user']; $pass=$_POST['pass']; $sql=SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'; $result=mysql_query($sql, $con); $count=mysql_num_rows($result); if ($count==1){ $_SESSION['user'] = $user; header('location: home.php'); } else echo p style='color:red'Wrong Username or Password/p; } ? html head title/title link href=style.css rel=stylesheet type=text/css / /head body div id=main div id=menu ul li a href=#Home/a /li li a href=#Topix/a /li li a href=#Mission/a /li /ul /div div id='content' form method='post' action='index.php' Username: br/ input type='text' name='user' maxlength='30'/br/ Password: br/ input type=password name='pass' maxlength='30'/br/ input type=submit value=Log In! name=login/ /form a href=register.html Register? /a /div /body /html
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
Thanks! -- I'll definitely look into Netbeans. (The IDE that I was using didn't seem to recognize syntax errors.) On Mon, Feb 21, 2011 at 4:13 AM, Pete Ford p...@justcroft.com wrote: Nazish, Find yourself an editor or development environment that does source code highlighting - this sort of error will be very obvious in such a program. I'm not going to recommend one - that's a sure way to start an argument - but I use Netbeans. Cheers Pete -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Submitting data to MySQL database using HTML/PHP form
Hi there, I am creating a login page for my website. The users' information will be stored in a MySQL database. I have a registration form on my home page, and a separate file called login.php to process the user values. However, the entries are not going to the MySQL database (however, the values can be entered successfully using the command line). I'd appreciate your insight on why the form entries are not making their way to the MySQL database. Much thanks in advance! This is the code for the form: form action='login.php' method='POST' Username: input type='text' name='login'br Password: input type='password' name='password'br input type='submit' value='Submit' /form This is the code in login.php: ?php // Connect to server and select database. $host = localhost; $user = root; $password = abc; $db = directory; mysql_connect($host, $user, $password) or die(could not connect!); mysql_select_db($db) or die(mysql_error()); // username and password sent to table user_info in mysql $login = $_POST['login']; $password = $_POST['password']; $insert = INSERT INTO user_info (login, password) VALUES ($login, $password); mysql_query($insert); ? It's a simple form which I will develop further once the basic submission process has been ironed out... Thanks again for any insight!
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
On Sun, Feb 20, 2011 at 12:55, Daniel Brown danbr...@php.net wrote: On Sun, Feb 20, 2011 at 12:53, Daniel Brown danbr...@php.net wrote: If the value isn't that of your database password, there's your problem: register_globals. A simpler way is to check the output of phpinfo(); to see if register_globals is enabled, but either method will work. Actually, disregard my answer: I misread your original email about where each line of code was placed. My answer is not correct in this case. Does your login.php file actually use the following closing tag: ? If so, that's backwards, which will cause a parse error on login.php. Closing tags should be ?, but if it's the last line in a file, you can safely (and perhaps should) omit them. Also, some other pointers: * ALWAYS sanitize user input. At the very least, look into mysql_real_escape_string(). * Don't use the same variable name for multiple things unless you need to do so. It makes debugging more difficult in complex scripts. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
Update: I added echo statements after mysql_connect and mysql_select_db to check where the code was broken. These statements show up on the login.php page after submitting the form, which means the MySQL connection works. So, the problem seems to lie with the *$insert *query... ideas? On Sun, Feb 20, 2011 at 3:04 PM, Nazish naz...@gmail.com wrote: Thanks everyone! However, when I click the submit button, the url simply moves to http://localhost/login.php (from home.php) and it is a blank page (apart from asking whether it should remember the password for future use). The values still do not move to the database. I included most of your suggestions a) added mysql _error() b) different names for the variables c) removed double quotes d) changed ? (silly error!) e) modified the $insert query The code now looks like this: ?php // Connect to server and select database. $host = localhost; $user = root; $mysql_pass = abc; $db = directory; mysql_connect($host, $user, $mysql_pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); // username and password sent to mysql database $login = $_POST['login']; $password = $_POST['password']; $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($password).'); mysql_query($insert) or die (Unable to add user to the database:.mysql_error()); ? I could insert the values using the command line, and it was updated in MySQL, but it doesn't work through the form... it just goes to a blank page on login.php. I'd appreciate any insights on why that's happening.
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
Issue resolved! It turned out to be the use of quotations. Instead of double quotations to surround the $insert variable, it worked with single quotations: $insert = ' INSERT INTO user_info (login,password) VALUES ('.$login.', '.$password.') ' ; With the real_escape_string, this version worked (double quotation on the outside, single quotation on the inside): ( '.mysql_real_escape_string($login).' , '.mysql_real_escape_string($password).' )'; I'm not sure why the use of quotations works differently in different cases? Thanks for your insights! It really helped with diagnostics. Much appreciated! On Sun, Feb 20, 2011 at 3:59 PM, ad...@buskirkgraphics.com wrote: I see an errors in the syntax. $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($passwor d).'); Issues resolved. $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($passwor d).'); Here is the issue , '.mysql_real_escape_string($password). ' Your escaping incorrectly. It should be ,' .mysql_real_escape_string($password). ' The double quote is in the wrong place. -Original Message- From: Nazish [mailto:naz...@gmail.com] Sent: Sunday, February 20, 2011 3:54 PM To: php-general@lists.php.net Subject: Re: [PHP] Submitting data to MySQL database using HTML/PHP form Update: I added echo statements after mysql_connect and mysql_select_db to check where the code was broken. These statements show up on the login.php page after submitting the form, which means the MySQL connection works. So, the problem seems to lie with the *$insert *query... ideas? On Sun, Feb 20, 2011 at 3:04 PM, Nazish naz...@gmail.com wrote: Thanks everyone! However, when I click the submit button, the url simply moves to http://localhost/login.php (from home.php) and it is a blank page (apart from asking whether it should remember the password for future use). The values still do not move to the database. I included most of your suggestions a) added mysql _error() b) different names for the variables c) removed double quotes d) changed ? (silly error!) e) modified the $insert query The code now looks like this: ?php // Connect to server and select database. $host = localhost; $user = root; $mysql_pass = abc; $db = directory; mysql_connect($host, $user, $mysql_pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); // username and password sent to mysql database $login = $_POST['login']; $password = $_POST['password']; $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($passwor d).'); mysql_query($insert) or die (Unable to add user to the database:.mysql_error()); ? I could insert the values using the command line, and it was updated in MySQL, but it doesn't work through the form... it just goes to a blank page on login.php. I'd appreciate any insights on why that's happening.
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
Hello Nazish, Try to do the following in your login.php: ?php print_r($_POST); // assign your variables echo br$loginbr$passwordbr$insertbr; So we'll see the result. -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Original message From: Nazish naz...@gmail.com To: php-general@lists.php.net Date created: , 10:04:07 PM Subject: [PHP] Submitting data to MySQL database using HTML/PHP form Thanks everyone! However, when I click the submit button, the url simply moves to http://localhost/login.php (from home.php) and it is a blank page (apart from asking whether it should remember the password for future use). The values still do not move to the database. I included most of your suggestions a) added mysql _error() b) different names for the variables c) removed double quotes d) changed ? (silly error!) e) modified the $insert query The code now looks like this: ?php // Connect to server and select database. $host = localhost; $user = root; $mysql_pass = abc; $db = directory; mysql_connect($host, $user, $mysql_pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); // username and password sent to mysql database $login = $_POST['login']; $password = $_POST['password']; $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($password).'); mysql_query($insert) or die (Unable to add user to the database:.mysql_error()); ? I could insert the values using the command line, and it was updated in MySQL, but it doesn't work through the form... it just goes to a blank page on login.php. I'd appreciate any insights on why that's happening. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
Hello Nazish, Echo the $insert variable. -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Original message From: Nazish naz...@gmail.com To: php-general@lists.php.net Date created: , 10:53:35 PM Subject: [PHP] Submitting data to MySQL database using HTML/PHP form Update: I added echo statements after mysql_connect and mysql_select_db to check where the code was broken. These statements show up on the login.php page after submitting the form, which means the MySQL connection works. So, the problem seems to lie with the *$insert *query... ideas? On Sun, Feb 20, 2011 at 3:04 PM, Nazish naz...@gmail.com wrote: Thanks everyone! However, when I click the submit button, the url simply moves to http://localhost/login.php (from home.php) and it is a blank page (apart from asking whether it should remember the password for future use). The values still do not move to the database. I included most of your suggestions a) added mysql _error() b) different names for the variables c) removed double quotes d) changed ? (silly error!) e) modified the $insert query The code now looks like this: ?php // Connect to server and select database. $host = localhost; $user = root; $mysql_pass = abc; $db = directory; mysql_connect($host, $user, $mysql_pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); // username and password sent to mysql database $login = $_POST['login']; $password = $_POST['password']; $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($password).'); mysql_query($insert) or die (Unable to add user to the database:.mysql_error()); ? I could insert the values using the command line, and it was updated in MySQL, but it doesn't work through the form... it just goes to a blank page on login.php. I'd appreciate any insights on why that's happening. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Submitting data to MySQL database using HTML/PHP form
I see an errors in the syntax. $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($passwor d).'); Issues resolved. $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($passwor d).'); Here is the issue ,'.mysql_real_escape_string($password).' Your escaping incorrectly. It should be ,'.mysql_real_escape_string($password).' The double quote is in the wrong place. -Original Message- From: Nazish [mailto:naz...@gmail.com] Sent: Sunday, February 20, 2011 3:54 PM To: php-general@lists.php.net Subject: Re: [PHP] Submitting data to MySQL database using HTML/PHP form Update: I added echo statements after mysql_connect and mysql_select_db to check where the code was broken. These statements show up on the login.php page after submitting the form, which means the MySQL connection works. So, the problem seems to lie with the *$insert *query... ideas? On Sun, Feb 20, 2011 at 3:04 PM, Nazish naz...@gmail.com wrote: Thanks everyone! However, when I click the submit button, the url simply moves to http://localhost/login.php (from home.php) and it is a blank page (apart from asking whether it should remember the password for future use). The values still do not move to the database. I included most of your suggestions a) added mysql _error() b) different names for the variables c) removed double quotes d) changed ? (silly error!) e) modified the $insert query The code now looks like this: ?php // Connect to server and select database. $host = localhost; $user = root; $mysql_pass = abc; $db = directory; mysql_connect($host, $user, $mysql_pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); // username and password sent to mysql database $login = $_POST['login']; $password = $_POST['password']; $insert = INSERT INTO user_info (login, password) VALUES ('.mysql_real_escape_string($login).','.mysql_real_escape_string($passwor d).'); mysql_query($insert) or die (Unable to add user to the database:.mysql_error()); ? I could insert the values using the command line, and it was updated in MySQL, but it doesn't work through the form... it just goes to a blank page on login.php. I'd appreciate any insights on why that's happening. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
I'm wondering if anyone is going to comment on the transmittal and storage of plain text passwords -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Submitting data to MySQL database using HTML/PHP form
Hello Tamara, :-)) I assume that was a testcase... -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Original message From: Tamara Temple tamouse.li...@gmail.com To: PHP General Date created: , 12:27:46 AM Subject: [PHP] Submitting data to MySQL database using HTML/PHP form I'm wondering if anyone is going to comment on the transmittal and storage of plain text passwords -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form Processing
I am unable to retrieve the value of $referral_1 from: $new_email = mysql_escape_string ( $_POST['referral_$i'] ); why? PHP while lopp to check if any of the fields were populated: $i=1; while ( $i = 5 ) { $new_email = mysql_escape_string ( $_POST['referral_$i'] ); if ( strlen ( $new_email ) 0 ) { } } The form itself: form method=post action=”website” p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_1 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_2 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_3 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_4 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_5 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=submit name=submit value=Add New Referrals/p /form What am I doing wrong? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
Re: [PHP] Form Processing
On Monday 29 November 2010, Ron Piggott ron.pigg...@actsministries.org wrote: I am unable to retrieve the value of $referral_1 from: That's very simple, you are missing the name attribute for your input elements, for example: input type=text name=email maxlength=60 class=referral_5 style=width: 400px; Should be: input type=text name=email maxlength=60 class=referral_5 name=referral_5 style=width: 400px; Please read the following links: HTML Standards: http://www.w3.org/standards/webdesign/htmlcss PHP Manual: http://cl.php.net/manual/en/ $new_email = mysql_escape_string ( $_POST['referral_$i'] ); why? PHP while lopp to check if any of the fields were populated: $i=1; while ( $i = 5 ) { $new_email = mysql_escape_string ( $_POST['referral_$i'] ); if ( strlen ( $new_email ) 0 ) { } } The form itself: form method=post action=”website” p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_1 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_2 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_3 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_4 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=text name=email maxlength=60 class=referral_5 style=width: 400px;/p p style=margin: 10px 50px 10px 50px;input type=submit name=submit value=Add New Referrals/p /form What am I doing wrong? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info Best regards, -- Daniel Molina Wegener dmw [at] coder [dot] cl System Programmer Web Developer Phone: +56 (2) 979-0277 | Blog: http://coder.cl/ signature.asc Description: This is a digitally signed message part.
Re: [PHP] Form Processing
On Mon, Nov 29, 2010 at 18:54, Ron Piggott ron.pigg...@actsministries.org wrote: $new_email = mysql_escape_string ( $_POST['referral_$i'] ); Because you're using literal quotes, so PHP is literally looking for the POST reference 'referral_$i'. Instead of using the style of field names you're using, why not use a virtually limitless array? ?php if (isset($_POST['referral']) is_array($_POST['referral'])) { $refcnt = count($_POST['referral']); for ($i=0;$i$refcnt;$i++) { echo 'Referral #'.$i.': '.$_POST['referral'][$i].'br/'.PHP_EOL; } } ? form method=post action=?php echo $_SERVER['PHP_SELF']; ? ?php for ($i=1;$i6;$i++) { echo ' nbsp; nbsp;input type=text name=referral[] id=referral_'.$i.'/br/'.PHP_EOL; } ? input type=submit id=submitButton value=Send/ /form -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form post question
I have a form which has the following: ( quick clip ) form id=form1 name=form1 method=post action=http://www.abc.com/processing/process_form.php; onSubmit=return preSubmit(); label input name=area_interest type=checkbox id=field13 value=Peer Guide / Peer Guide/label br / label input type=submit value=Submit / When the form runs process_form.php it emails the content and has several other fields from the form, but I have some fields like the one above that don't show up in the result. The script that builds the message looks like the below $temp_message .= Area(s) of Interest: . $_POST['area_interest'] .\n; Is there anything obvious that I am missing? Is there a way for me to show all the fields from the form, and their field names which are received by process_form? Thanks! Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form post question
On Thu, Oct 28, 2010 at 10:12 AM, Jack jacklistm...@gmail.com wrote: I have a form which has the following: ( quick clip ) form id=form1 name=form1 method=post action=http://www.abc.com/processing/process_form.php; onSubmit=return preSubmit(); label input name=area_interest type=checkbox id=field13 value=Peer Guide / Peer Guide/label br / label input type=submit value=Submit / When the form runs process_form.php it emails the content and has several other fields from the form, but I have some fields like the one above that don't show up in the result. The script that builds the message looks like the below $temp_message .= Area(s) of Interest: . $_POST['area_interest'] .\n; Is there anything obvious that I am missing? Is there a way for me to show all the fields from the form, and their field names which are received by process_form? Thanks! Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Check boxes (assuming you have more than one in the set) are generally coming in as an array. You can see this by running this echo pre; print_r($_POST); echo /pre; to see the entire post array -- 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] form post question
On Oct 28, 2010, at 10:12 AM, Jack wrote: I have a form which has the following: ( quick clip ) form id=form1 name=form1 method=post action=http://www.abc.com/processing/process_form.php; onSubmit=return preSubmit(); label input name=area_interest type=checkbox id=field13 value=Peer Guide / Peer Guide/label br / label input type=submit value=Submit / When the form runs process_form.php it emails the content and has several other fields from the form, but I have some fields like the one above that don't show up in the result. The script that builds the message looks like the below $temp_message .= Area(s) of Interest: . $_POST['area_interest'] .\n; Is there anything obvious that I am missing? Is there a way for me to show all the fields from the form, and their field names which are received by process_form? Thanks! Jack If it's a single checkbox and it's not not checked, nothing will come through. However, if it is a series of checkbox with the same name then you will need to do this: input name=area_interest[] type=checkbox id=field13 value=Peer Guide / Notice I changed area_interest to area_interest[]. This way any checkboxes that are checked will be passed as an array. Take care, Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form post question
Bastien Koert wrote: On Thu, Oct 28, 2010 at 10:12 AM, Jack jacklistm...@gmail.com wrote: I have a form which has the following: ( quick clip ) form id=form1 name=form1 method=post action=http://www.abc.com/processing/process_form.php; onSubmit=return preSubmit(); label input name=area_interest type=checkbox id=field13 value=Peer Guide / Peer Guide/label br / label input type=submit value=Submit / When the form runs process_form.php it emails the content and has several other fields from the form, but I have some fields like the one above that don't show up in the result. The script that builds the message looks like the below $temp_message .= Area(s) of Interest: . $_POST['area_interest'] .\n; Is there anything obvious that I am missing? Is there a way for me to show all the fields from the form, and their field names which are received by process_form? Thanks! Jack Check boxes (assuming you have more than one in the set) are generally coming in as an array. You can see this by running this echo pre; print_r($_POST); echo /pre; to see the entire post array +1 for Bastien; print_r() and var_dump() are the keys to debugging. See http://www.phpbuilder.com/board/showthread.php?s=threadid=10240608 for a decent overview of same. And I guess you could reinvent the wheel, or actually process your POSTed data, with foreach(): // Roll your own print_r() foreach ($_POST as $p = $q) { echo $p. -.$q. br /; } // Or do_something_useful() foreach ($_POST as $p = $q) { do_something_useful($p,$q); } HTH, KDK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation and error display
Hello Everyone, Thanks for all the suggestions on my sticky form problem. I've changed my action attribute to empty as per the article on PHP_SELF. I'm still having an issue getting the form to redisplay. For example, if i don't fill out the name field how would i get the form to redisplay with all the rest of the entered values? I've got text values working, but combo boxes are not. I've got three values i'll take the type one here, one is zero and it's choice is to select an option. That's a required field, so if it's skipped zero is given, I want to indicate that's not valid and redisplay the form. Event is 1 and meeting is 2 or maybe i've got those reversed but it doesn't matter. So, say I select 2 for meeting or event or whatever, but again i don't fill in the name field. I want the form to redisplay, but to have the combo box values filled in. I'm certain this is conceptual and coding on my part, I'd appreciate any assistance. Thanks. Dave. On 7/4/10, Paul M Foster pa...@quillandmouse.com wrote: On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote: Hello, I've got a form with several required fields of different types. I want to have the php script process it only when all the required fields are present, and to redisplay the form with filled in values on failure so the user won't have to fill out the whole thing again. One of my required fields is a text input field called name. If it's not filled out the form displayed will show this: input type=text name=name id=name size=50 value=?php echo($name); ? / br / Note, I've got $_POST* variable processing before this so am assigning that processing to short variables. If that field is filled out, but another required one is not that form field will fill in the value entered for the name field. This is working for my text input fields, but not for either select boxes or textareas. Here's the textarea also a required field: textarea name=description id=description cols=50 rows=10 value=?php echo($description); ?/textarea Textarea fields don't work this way. To display the prior value, you have to do this: textarea name=description?php echo $description; ?/textarea What this does, if a user fills out this field, but misses another, it should echo the value of what was originally submitted. It is not doing this. Same for my select boxes, here's one: select name=type id=type value=?php echo($type); ? option value=0 selected=selected-- select type --/option option value=meeting - Meeting - /option option value=event - Event - /option /select The value attribute of a select field won't do this for you. You have to actually set up each option with an either/or choice, like this: option value=0 ?php if ($type == 'meeting') echo 'selected=selected'; ? - Meeting - /option Since doing this is pretty tedious, I use a function here instead: function set_selected($fieldname, $value) { if ($_POST[$fieldname] == $value) echo 'selected=selected'; } And then option value=meeting ?php set_selected('type', 'meeting'); ?Meeting/option HTH, Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation and error display
Ash - Thanks for correcting me [should I say us ;) ]. So, if my understandng is right, we should use # instead of the superglobal variable. David - Sorry to have written that. I was not aware of the implications of the grand old way of doing it. :) Regards, Shreyas On Mon, Jul 5, 2010 at 4:24 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sun, 2010-07-04 at 18:23 -0400, David Mehler wrote: Hello everyone, Thanks for your suggestions. For my variable in the value area of the text input field I enter value=?php echo $name; ? Prior to this I assign the variable $name to: $name = stripslashes($_POST['name']); I hope this is correct. Sticky forms sounds exactly what i'm looking for. I've changed my action attribute to ?php echo $_SERVER['PHP_SELF']; ? The first thing I do once the page is loaded is check whether or not submit is set, if it is not I display the form, which is in a function call. If submit is set I want to begtin validation, so i'm deciding to merge my two files in to one, I like this better. My question is say for example the name text field is not filled out but all the other required fields are how do I get the form to redisplay itself? I was thinking a location redirect, but this doesn't sound right. Thanks. Dave. On 7/4/10, Paul M Foster pa...@quillandmouse.com wrote: On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote: Hello, I've got a form with several required fields of different types. I want to have the php script process it only when all the required fields are present, and to redisplay the form with filled in values on failure so the user won't have to fill out the whole thing again. One of my required fields is a text input field called name. If it's not filled out the form displayed will show this: input type=text name=name id=name size=50 value=?php echo($name); ? / br / Note, I've got $_POST* variable processing before this so am assigning that processing to short variables. If that field is filled out, but another required one is not that form field will fill in the value entered for the name field. This is working for my text input fields, but not for either select boxes or textareas. Here's the textarea also a required field: textarea name=description id=description cols=50 rows=10 value=?php echo($description); ?/textarea Textarea fields don't work this way. To display the prior value, you have to do this: textarea name=description?php echo $description; ?/textarea What this does, if a user fills out this field, but misses another, it should echo the value of what was originally submitted. It is not doing this. Same for my select boxes, here's one: select name=type id=type value=?php echo($type); ? option value=0 selected=selected-- select type --/option option value=meeting - Meeting - /option option value=event - Event - /option /select The value attribute of a select field won't do this for you. You have to actually set up each option with an either/or choice, like this: option value=0 ?php if ($type == 'meeting') echo 'selected=selected'; ? - Meeting - /option Since doing this is pretty tedious, I use a function here instead: function set_selected($fieldname, $value) { if ($_POST[$fieldname] == $value) echo 'selected=selected'; } And then option value=meeting ?php set_selected('type', 'meeting'); ?Meeting/option HTH, Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $_SERVER['PHP_SELF'] is not to be trusted, and shouldn't be used as the action of a form like this. http://www.mc2design.com/blog/php_self-safe-alternatives explains it all better than I can here, so it's worth a read, but it does list safe alternatives. One thing I do when creating sticky select lists is this: $colours = array('red', 'green', 'blue', 'yellow', 'pink'); echo 'select name=colour'; for($i=0; $icount($colours); $i++) { $selected = (isset($_POST['colour']) $_POST['colour'] == $i)?'selected=selected':''; echo option value=\$i\ $selected{$colours[$i]}/option; } echo '/select'; Basically, this uses PHP to not only output the list from an array (which itself can be populated from a database maybe) and select the right option if it exists in the $_POST array and matches the current option in the loop that's being output. Thanks, Ash http://www.ashleysheridan.co.uk -- Regards, Shreyas Agasthya
[PHP] form validation and error display
Hello, I've got a form with several required fields of different types. I want to have the php script process it only when all the required fields are present, and to redisplay the form with filled in values on failure so the user won't have to fill out the whole thing again. One of my required fields is a text input field called name. If it's not filled out the form displayed will show this: input type=text name=name id=name size=50 value=?php echo($name); ? / br / Note, I've got $_POST* variable processing before this so am assigning that processing to short variables. If that field is filled out, but another required one is not that form field will fill in the value entered for the name field. This is working for my text input fields, but not for either select boxes or textareas. Here's the textarea also a required field: textarea name=description id=description cols=50 rows=10 value=?php echo($description); ?/textarea What this does, if a user fills out this field, but misses another, it should echo the value of what was originally submitted. It is not doing this. Same for my select boxes, here's one: select name=type id=type value=?php echo($type); ? option value=0 selected=selected-- select type --/option option value=meeting - Meeting - /option option value=event - Event - /option /select I'd also like for any not entered required fields to have an error box around them, I've got a css class to handle this, but am not sure how to tie it in to the fields since any one of the required fields could not be filled in. I'd appreciate any help. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation and error display
David, If I understand your problem/issue here, you are talking about something called 'sticky forms'. This means - (i) the form references itself. (ii) that the form knows what the previous data was when it encounters any validation issues. You achieve (i) and (ii) by re-submitting the form with the usage of a superglobal variable called $_SERVER['PHP_SELF']. form method='POST' action =php echo $_SERVER['PHP_SELF'] ? Regards, Shreyas On Sun, Jul 4, 2010 at 11:27 PM, David Mehler dave.meh...@gmail.com wrote: Hello, I've got a form with several required fields of different types. I want to have the php script process it only when all the required fields are present, and to redisplay the form with filled in values on failure so the user won't have to fill out the whole thing again. One of my required fields is a text input field called name. If it's not filled out the form displayed will show this: input type=text name=name id=name size=50 value=?php echo($name); ? / br / Note, I've got $_POST* variable processing before this so am assigning that processing to short variables. If that field is filled out, but another required one is not that form field will fill in the value entered for the name field. This is working for my text input fields, but not for either select boxes or textareas. Here's the textarea also a required field: textarea name=description id=description cols=50 rows=10 value=?php echo($description); ?/textarea What this does, if a user fills out this field, but misses another, it should echo the value of what was originally submitted. It is not doing this. Same for my select boxes, here's one: select name=type id=type value=?php echo($type); ? option value=0 selected=selected-- select type --/option option value=meeting - Meeting - /option option value=event - Event - /option /select I'd also like for any not entered required fields to have an error box around them, I've got a css class to handle this, but am not sure how to tie it in to the fields since any one of the required fields could not be filled in. I'd appreciate any help. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Shreyas Agasthya
Re: [PHP] form validation and error display
On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote: Hello, I've got a form with several required fields of different types. I want to have the php script process it only when all the required fields are present, and to redisplay the form with filled in values on failure so the user won't have to fill out the whole thing again. One of my required fields is a text input field called name. If it's not filled out the form displayed will show this: input type=text name=name id=name size=50 value=?php echo($name); ? / br / Note, I've got $_POST* variable processing before this so am assigning that processing to short variables. If that field is filled out, but another required one is not that form field will fill in the value entered for the name field. This is working for my text input fields, but not for either select boxes or textareas. Here's the textarea also a required field: textarea name=description id=description cols=50 rows=10 value=?php echo($description); ?/textarea Textarea fields don't work this way. To display the prior value, you have to do this: textarea name=description?php echo $description; ?/textarea What this does, if a user fills out this field, but misses another, it should echo the value of what was originally submitted. It is not doing this. Same for my select boxes, here's one: select name=type id=type value=?php echo($type); ? option value=0 selected=selected-- select type --/option option value=meeting - Meeting - /option option value=event - Event - /option /select The value attribute of a select field won't do this for you. You have to actually set up each option with an either/or choice, like this: option value=0 ?php if ($type == 'meeting') echo 'selected=selected'; ? - Meeting - /option Since doing this is pretty tedious, I use a function here instead: function set_selected($fieldname, $value) { if ($_POST[$fieldname] == $value) echo 'selected=selected'; } And then option value=meeting ?php set_selected('type', 'meeting'); ?Meeting/option HTH, Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation and error display
Hello everyone, Thanks for your suggestions. For my variable in the value area of the text input field I enter value=?php echo $name; ? Prior to this I assign the variable $name to: $name = stripslashes($_POST['name']); I hope this is correct. Sticky forms sounds exactly what i'm looking for. I've changed my action attribute to ?php echo $_SERVER['PHP_SELF']; ? The first thing I do once the page is loaded is check whether or not submit is set, if it is not I display the form, which is in a function call. If submit is set I want to begtin validation, so i'm deciding to merge my two files in to one, I like this better. My question is say for example the name text field is not filled out but all the other required fields are how do I get the form to redisplay itself? I was thinking a location redirect, but this doesn't sound right. Thanks. Dave. On 7/4/10, Paul M Foster pa...@quillandmouse.com wrote: On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote: Hello, I've got a form with several required fields of different types. I want to have the php script process it only when all the required fields are present, and to redisplay the form with filled in values on failure so the user won't have to fill out the whole thing again. One of my required fields is a text input field called name. If it's not filled out the form displayed will show this: input type=text name=name id=name size=50 value=?php echo($name); ? / br / Note, I've got $_POST* variable processing before this so am assigning that processing to short variables. If that field is filled out, but another required one is not that form field will fill in the value entered for the name field. This is working for my text input fields, but not for either select boxes or textareas. Here's the textarea also a required field: textarea name=description id=description cols=50 rows=10 value=?php echo($description); ?/textarea Textarea fields don't work this way. To display the prior value, you have to do this: textarea name=description?php echo $description; ?/textarea What this does, if a user fills out this field, but misses another, it should echo the value of what was originally submitted. It is not doing this. Same for my select boxes, here's one: select name=type id=type value=?php echo($type); ? option value=0 selected=selected-- select type --/option option value=meeting - Meeting - /option option value=event - Event - /option /select The value attribute of a select field won't do this for you. You have to actually set up each option with an either/or choice, like this: option value=0 ?php if ($type == 'meeting') echo 'selected=selected'; ? - Meeting - /option Since doing this is pretty tedious, I use a function here instead: function set_selected($fieldname, $value) { if ($_POST[$fieldname] == $value) echo 'selected=selected'; } And then option value=meeting ?php set_selected('type', 'meeting'); ?Meeting/option HTH, Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation and error display
On Sun, 2010-07-04 at 18:23 -0400, David Mehler wrote: Hello everyone, Thanks for your suggestions. For my variable in the value area of the text input field I enter value=?php echo $name; ? Prior to this I assign the variable $name to: $name = stripslashes($_POST['name']); I hope this is correct. Sticky forms sounds exactly what i'm looking for. I've changed my action attribute to ?php echo $_SERVER['PHP_SELF']; ? The first thing I do once the page is loaded is check whether or not submit is set, if it is not I display the form, which is in a function call. If submit is set I want to begtin validation, so i'm deciding to merge my two files in to one, I like this better. My question is say for example the name text field is not filled out but all the other required fields are how do I get the form to redisplay itself? I was thinking a location redirect, but this doesn't sound right. Thanks. Dave. On 7/4/10, Paul M Foster pa...@quillandmouse.com wrote: On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote: Hello, I've got a form with several required fields of different types. I want to have the php script process it only when all the required fields are present, and to redisplay the form with filled in values on failure so the user won't have to fill out the whole thing again. One of my required fields is a text input field called name. If it's not filled out the form displayed will show this: input type=text name=name id=name size=50 value=?php echo($name); ? / br / Note, I've got $_POST* variable processing before this so am assigning that processing to short variables. If that field is filled out, but another required one is not that form field will fill in the value entered for the name field. This is working for my text input fields, but not for either select boxes or textareas. Here's the textarea also a required field: textarea name=description id=description cols=50 rows=10 value=?php echo($description); ?/textarea Textarea fields don't work this way. To display the prior value, you have to do this: textarea name=description?php echo $description; ?/textarea What this does, if a user fills out this field, but misses another, it should echo the value of what was originally submitted. It is not doing this. Same for my select boxes, here's one: select name=type id=type value=?php echo($type); ? option value=0 selected=selected-- select type --/option option value=meeting - Meeting - /option option value=event - Event - /option /select The value attribute of a select field won't do this for you. You have to actually set up each option with an either/or choice, like this: option value=0 ?php if ($type == 'meeting') echo 'selected=selected'; ? - Meeting - /option Since doing this is pretty tedious, I use a function here instead: function set_selected($fieldname, $value) { if ($_POST[$fieldname] == $value) echo 'selected=selected'; } And then option value=meeting ?php set_selected('type', 'meeting'); ?Meeting/option HTH, Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $_SERVER['PHP_SELF'] is not to be trusted, and shouldn't be used as the action of a form like this. http://www.mc2design.com/blog/php_self-safe-alternatives explains it all better than I can here, so it's worth a read, but it does list safe alternatives. One thing I do when creating sticky select lists is this: $colours = array('red', 'green', 'blue', 'yellow', 'pink'); echo 'select name=colour'; for($i=0; $icount($colours); $i++) { $selected = (isset($_POST['colour']) $_POST['colour'] == $i)?'selected=selected':''; echo option value=\$i\ $selected{$colours[$i]}/option; } echo '/select'; Basically, this uses PHP to not only output the list from an array (which itself can be populated from a database maybe) and select the right option if it exists in the $_POST array and matches the current option in the loop that's being output. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] form validation code
Hello, I've been looking at this to long, and am not seeing the issue. When i had the below php code set to !empty instead of !isset as it is now I got the value of the name variable echoed back, yet on sql insert that field, along with all others are empty, though no error is generated, just a bogus record is inserted. When I changed to !isset I'm now getting the die statement echoed as if no value was passed from the form. This is not the case, I filled it out completely. Can anyone tell me where this code went wrong? Thanks. Dave. Html form: h3Fields marked with a * (star) are required./h3 form method=post action= div label for=txtnameName*:/label input type=text name=name / br / /div div input id=reset name=reset type=reset/ /div div input id=submit name=submit type=submit/ /div /form /div php Code: // Check if fields are isset echo Field Checs.br /; if (!isset($_POST['name'])) { echo The value of Name is . $_POST['name']. br /; } else { die('ERROR: Missing value - Event Name'); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation code
On Wed, Jun 30, 2010 at 09:07, David Mehler dave.meh...@gmail.com wrote: Hello, I've been looking at this to long, and am not seeing the issue. When i had the below php code set to !empty instead of !isset as it is now I got the value of the name variable echoed back, yet on sql insert that field, along with all others are empty, though no error is generated, just a bogus record is inserted. When I changed to !isset I'm now getting the die statement echoed as if no value was passed from the form. This is not the case, I filled it out completely. Can anyone tell me where this code went wrong? Sure. php Code: // Check if fields are isset echo Field Checs.br /; if (!isset($_POST['name'])) { the line above. (Hint: isset != empty) (Another hint: with !empty(), you told PHP, if it's not empty. Now, with !isset(), you're saying, if it's not set.) (Answer: Remove the exclamation point from !isset().) -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation code
On 30 June 2010 14:23, Daniel P. Brown daniel.br...@parasane.net wrote: (Hint: isset != empty) More importantly ... isset != !empty $a = Null; $b = ''; // $c = undefined; $d = 'Hello'; isset($a) = False vs True = empty($a) isset($b) = True vs True = empty($b) isset($c) = False vs True = empty($c) isset($d) = True vs False = empty($d) -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form validation code
http://www.php.net/manual/en/types.comparisons.php http://www.php.net/manual/en/types.comparisons.phpThe first table actually gives a very good understanding. --Shreyas On Wed, Jun 30, 2010 at 7:05 PM, Richard Quadling rquadl...@gmail.comwrote: On 30 June 2010 14:23, Daniel P. Brown daniel.br...@parasane.net wrote: (Hint: isset != empty) More importantly ... isset != !empty $a = Null; $b = ''; // $c = undefined; $d = 'Hello'; isset($a) = False vs True = empty($a) isset($b) = True vs True = empty($b) isset($c) = False vs True = empty($c) isset($d) = True vs False = empty($d) -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Shreyas Agasthya
Re: [PHP] form validation code
On 30 June 2010 14:53, Shreyas Agasthya shreya...@gmail.com wrote: http://www.php.net/manual/en/types.comparisons.php The first table actually gives a very good understanding. --Shreyas On Wed, Jun 30, 2010 at 7:05 PM, Richard Quadling rquadl...@gmail.com wrote: On 30 June 2010 14:23, Daniel P. Brown daniel.br...@parasane.net wrote: (Hint: isset != empty) More importantly ... isset != !empty $a = Null; $b = ''; // $c = undefined; $d = 'Hello'; isset($a) = False vs True = empty($a) isset($b) = True vs True = empty($b) isset($c) = False vs True = empty($c) isset($d) = True vs False = empty($d) -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Shreyas Agasthya empty() === !boolean() and isset() === !is_null() -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Form submitting to MySQL not working...
Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Form submitting to MySQL not working...
On Thu, 2010-06-03 at 08:56 -0500, Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Do you have any examples of code at all? It sounds like a file it's requiring is missing, but you haven't given the full error there either. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP Form submitting to MySQL not working...
On Thu, Jun 3, 2010 at 7:26 PM, Steve Marquez smarq...@marquez-design.com wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php 1. Did you do any upgrades recently ? 2. What is your code ? -- Nilesh Govindarajan Facebook: nilesh.gr Twitter: nileshgr Website: www.itech7.com Cheap and Reliable VPS Hosting: http://j.mp/arHk5e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Form submitting to MySQL not working...
div id='menu'; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { extract ( $line ); $LimitChars = substr($prayer, 0, 65); echo div id='view_date' align='left'$view - $date/div; } echo /div; ? /div /body /htmlI downloaded and installed the iPhone SDK to develop some iPhone apps.This form has worked forever. Perhaps the SDK install did something?Thanks, --Steve MarquezMarquez Designe-mail: smarq...@marquez-design.comweb: http://www.marquez-design.comphone: 479-648-0325 On Jun 3, 2010, at 8:59 AM, Ashley Sheridan wrote: On Thu, 2010-06-03 at 08:56 -0500, Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Do you have any examples of code at all? It sounds like a file it's requiring is missing, but you haven't given the full error there either. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP Form submitting to MySQL not working...
Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Where exactly did you see this error? 1) In your browser when you tried loading the form? 2) In your browser when you submitted the form? 3) In the error logs of your web server? Other questions: What type of web server are you running? Did your cat stomp on your keyboard? Are the files stored locally or are they on a network/remote drive? Children doing things they should not be doing? (Happened to me once...) Are you accessing the files via http://localhost/... ?? or as a local file? -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Form submitting to MySQL not working...
Steve Marquez wrote: I am running Apache (not sure which version, where do I find that?) it is running on a Macbook Pro. The error happened when I submitted the form. Sorry, should have been more specific. Where did you see the error? In your browser, error logs of your web server, etc... ? If this error was displayed in your browser, you should look in your apache error log file at that corresponding time to see if it has any more information. The MySQL DB is hosted locally on my machine. No cat here at the office, no children either, they are all at home. :) -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Form submitting to MySQL not working...
-Original Message- From: Jim Lucas [mailto:li...@cmsws.com] Sent: Thursday, June 03, 2010 11:38 AM To: php General List Cc: Steve Marquez Subject: Re: [PHP] PHP Form submitting to MySQL not working... Steve Marquez wrote: I am running Apache (not sure which version, where do I find that?) it is running on a Macbook Pro. The error happened when I submitted the form. Sorry, should have been more specific. Where did you see the error? In your browser, error logs of your web server, etc... ? If this error was displayed in your browser, you should look in your apache error log file at that corresponding time to see if it has any more information. The MySQL DB is hosted locally on my machine. No cat here at the office, no children either, they are all at home. :) -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What did your error log file say? it should tell you the path and the name of the file that was being called; then go and look to see if the file exists. __ Information from ESET Smart Security, version of virus signature database 5169 (20100603) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Form submitting to MySQL not working...
Steve, SERVER_SOFTWARE is a variable that will give you which apache version you are actually using. Just drop a one - liner in a test.php as this : * * * ?php phpinfo(); ? * You can look for the above variable. Any other ideas others may have, please share. On Thu, Jun 3, 2010 at 9:31 PM, HallMarc Websites sa...@hallmarcwebsites.com wrote: -Original Message- From: Jim Lucas [mailto:li...@cmsws.com] Sent: Thursday, June 03, 2010 11:38 AM To: php General List Cc: Steve Marquez Subject: Re: [PHP] PHP Form submitting to MySQL not working... Steve Marquez wrote: I am running Apache (not sure which version, where do I find that?) it is running on a Macbook Pro. The error happened when I submitted the form. Sorry, should have been more specific. Where did you see the error? In your browser, error logs of your web server, etc... ? If this error was displayed in your browser, you should look in your apache error log file at that corresponding time to see if it has any more information. The MySQL DB is hosted locally on my machine. No cat here at the office, no children either, they are all at home. :) -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php On a side note; yes, as you can see I am still alive and well. Business has slowed down enough that I had time to actually read a few posts! Marc Hall HallMarc Websites www.hallmarcwebsites.com __ Information from ESET Smart Security, version of virus signature database 5169 (20100603) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Shreyas
RE: [PHP] PHP Form submitting to MySQL not working...
-Original Message- From: Jim Lucas [mailto:li...@cmsws.com] Sent: Thursday, June 03, 2010 11:38 AM To: php General List Cc: Steve Marquez Subject: Re: [PHP] PHP Form submitting to MySQL not working... Steve Marquez wrote: I am running Apache (not sure which version, where do I find that?) it is running on a Macbook Pro. The error happened when I submitted the form. Sorry, should have been more specific. Where did you see the error? In your browser, error logs of your web server, etc... ? If this error was displayed in your browser, you should look in your apache error log file at that corresponding time to see if it has any more information. The MySQL DB is hosted locally on my machine. No cat here at the office, no children either, they are all at home. :) -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php On a side note; yes, as you can see I am still alive and well. Business has slowed down enough that I had time to actually read a few posts! Marc Hall HallMarc Websites www.hallmarcwebsites.com __ Information from ESET Smart Security, version of virus signature database 5169 (20100603) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Form submitting to MySQL not working...
Strangest thing... it just started working again. Odd. Is there an easy way to view the error logs? As you can tell, I am still a novice at this. I am on Apache2 Thanks for your help. -- Steve Marquez Marquez Design e-mail: smarq...@marquez-design.com web: http://www.marquez-design.com phone: 479-648-0325 On Jun 3, 2010, at 9:53 AM, Jim Lucas wrote: Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Where exactly did you see this error? 1) In your browser when you tried loading the form? 2) In your browser when you submitted the form? 3) In the error logs of your web server? Other questions: What type of web server are you running? Did your cat stomp on your keyboard? Are the files stored locally or are they on a network/remote drive? Children doing things they should not be doing? (Happened to me once...) Are you accessing the files via http://localhost/... ?? or as a local file? -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
Re: [PHP] PHP Form submitting to MySQL not working...
On Thu, 2010-06-03 at 12:58 -0500, Steve Marquez wrote: Strangest thing... it just started working again. Odd. Is there an easy way to view the error logs? As you can tell, I am still a novice at this. I am on Apache2 Thanks for your help. It depends. On most Linux distros there are log viewers that let you look at all the different logs from one drop-down menu. Otherwise, the logs are all just text files, so you can view them in any text editor from kate to notepad to vim. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP Form submitting to MySQL not working...
Steve, Do you know where Apache is installed? If yes, you have something like error.log and access.log. Find them and nail them them down. I am a novice, too and the best way to learn is to answer here and getting corrected by other PHP gurus! So, all in the name of learning! :) --Shreyas On Thu, Jun 3, 2010 at 11:28 PM, Steve Marquez smarq...@marquez-design.comwrote: Strangest thing... it just started working again. Odd. Is there an easy way to view the error logs? As you can tell, I am still a novice at this. I am on Apache2 Thanks for your help. -- Steve Marquez Marquez Design e-mail: smarq...@marquez-design.com web: http://www.marquez-design.com phone: 479-648-0325 On Jun 3, 2010, at 9:53 AM, Jim Lucas wrote: Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Where exactly did you see this error? 1) In your browser when you tried loading the form? 2) In your browser when you submitted the form? 3) In the error logs of your web server? Other questions: What type of web server are you running? Did your cat stomp on your keyboard? Are the files stored locally or are they on a network/remote drive? Children doing things they should not be doing? (Happened to me once...) Are you accessing the files via http://localhost/... ?? or as a local file? -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- Regards, Shreyas
Re: [PHP] PHP Form submitting to MySQL not working...
On Fri, 2010-06-04 at 00:25 +0530, Shreyas wrote: Steve, Do you know where Apache is installed? If yes, you have something like error.log and access.log. Find them and nail them them down. I am a novice, too and the best way to learn is to answer here and getting corrected by other PHP gurus! So, all in the name of learning! :) --Shreyas On Thu, Jun 3, 2010 at 11:28 PM, Steve Marquez smarq...@marquez-design.comwrote: Strangest thing... it just started working again. Odd. Is there an easy way to view the error logs? As you can tell, I am still a novice at this. I am on Apache2 Thanks for your help. -- Steve Marquez Marquez Design e-mail: smarq...@marquez-design.com web: http://www.marquez-design.com phone: 479-648-0325 On Jun 3, 2010, at 9:53 AM, Jim Lucas wrote: Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Where exactly did you see this error? 1) In your browser when you tried loading the form? 2) In your browser when you submitted the form? 3) In the error logs of your web server? Other questions: What type of web server are you running? Did your cat stomp on your keyboard? Are the files stored locally or are they on a network/remote drive? Children doing things they should not be doing? (Happened to me once...) Are you accessing the files via http://localhost/... ?? or as a local file? -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? You haven't said what sort of operating system you're using. In Linux, most of the logs are kept in sub-directories of /var/log I believe. Windows, well they could be scattered anywhere. MacOS, not too sure about that. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP Form submitting to MySQL not working...
True. Since I am a Windows user, I find it here : *C:\Program Files\EasyPHP 3.0\apache\logs* --Shreyas On Fri, Jun 4, 2010 at 12:27 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Fri, 2010-06-04 at 00:25 +0530, Shreyas wrote: Steve, Do you know where Apache is installed? If yes, you have something like error.log and access.log. Find them and nail them them down. I am a novice, too and the best way to learn is to answer here and getting corrected by other PHP gurus! So, all in the name of learning! :) --Shreyas On Thu, Jun 3, 2010 at 11:28 PM, Steve Marquez smarq...@marquez-design.comwrote: Strangest thing... it just started working again. Odd. Is there an easy way to view the error logs? As you can tell, I am still a novice at this. I am on Apache2 Thanks for your help. -- Steve Marquez Marquez Design e-mail: smarq...@marquez-design.com web: http://www.marquez-design.com phone: 479-648-0325 On Jun 3, 2010, at 9:53 AM, Jim Lucas wrote: Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Where exactly did you see this error? 1) In your browser when you tried loading the form? 2) In your browser when you submitted the form? 3) In the error logs of your web server? Other questions: What type of web server are you running? Did your cat stomp on your keyboard? Are the files stored locally or are they on a network/remote drive? Children doing things they should not be doing? (Happened to me once...) Are you accessing the files via http://localhost/... ?? or as a local file? -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? You haven't said what sort of operating system you're using. In Linux, most of the logs are kept in sub-directories of /var/log I believe. Windows, well they could be scattered anywhere. MacOS, not too sure about that. Thanks, Ash http://www.ashleysheridan.co.uk -- Regards, Shreyas
Re: [PHP] PHP Form submitting to MySQL not working...
I am on Mac OS 10.6 I found the logs using the console. It was pretty easy and displays nicely. I am reviewing the entries now. Thanks for your help. -- Steve Marquez Marquez Design e-mail: smarq...@marquez-design.com web: http://www.marquez-design.com phone: 479-648-0325 On Jun 3, 2010, at 1:55 PM, Shreyas wrote: Steve, Do you know where Apache is installed? If yes, you have something like error.log and access.log. Find them and nail them them down. I am a novice, too and the best way to learn is to answer here and getting corrected by other PHP gurus! So, all in the name of learning! :) --Shreyas On Thu, Jun 3, 2010 at 11:28 PM, Steve Marquez smarq...@marquez-design.com wrote: Strangest thing... it just started working again. Odd. Is there an easy way to view the error logs? As you can tell, I am still a novice at this. I am on Apache2 Thanks for your help. -- Steve Marquez Marquez Design e-mail: smarq...@marquez-design.com web: http://www.marquez-design.com phone: 479-648-0325 On Jun 3, 2010, at 9:53 AM, Jim Lucas wrote: Steve Marquez wrote: Good morning, I have a PHP form that I have been using for some time now on a Macbook Pro running PHP 5.3.1 and MySQL 5.0.5 and everything was working fine. But this morning, when I submitted (it is a journaling application) it came up with the following error: No such file or directory Can anyone point me in the right direction to fix this? Have you ever seen this before? Thanks, Steve Marquez Where exactly did you see this error? 1) In your browser when you tried loading the form? 2) In your browser when you submitted the form? 3) In the error logs of your web server? Other questions: What type of web server are you running? Did your cat stomp on your keyboard? Are the files stored locally or are they on a network/remote drive? Children doing things they should not be doing? (Happened to me once...) Are you accessing the files via http://localhost/... ?? or as a local file? -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- Regards, Shreyas
RE: [PHP] Dynamic Menus in a PHP Form Issue
-Original Message- From: Alice Wei [mailto:aj...@alumni.iu.edu] Sent: 24 May 2010 04:47 PM To: php-general@lists.php.net Subject: [PHP] Dynamic Menus in a PHP Form Issue Hi,I have a snippet as in the following: ul liSelect the type of your starting point of interest:br/ div id=start_menuform action= name=form1 method=post spaninput type=radio value=Apartment name=start onclick=alert(document.form1.start)/ Apartment /span /form/div/li/ulIf I tried to put this at the top of a file where I save as PHP with other PHP execution statements, looks like the form does not do anything, and yet when I save the page as in HTML with out the other PHP execution, it works. I am trying to create a page where I have dynamic drop down menu lists so users can egenerate dynamic content based on their preference. Is it possible that I can save the entire file as a PHP and still keep the functionality, including generating dynamic menus, writing the proper entries to the database and printing out the proper output? Thanks for your help. Alice _ The reason it works in html is because it is executed in the browser. If you want this html to get to the browser you must either echo it to the output buffer that is sent to the browser, or end your php section with ? so that these lines are interpreted as part of the output that is sent to the browser. If your php script is running without error then I presume you're already doing this. If that's the case then maybe it's not being put into the output buffer the way you're expecting (e.g. maybe the quotes don't match). You can look at the source code in the browser and compare it against the working html code to see where the difference is. Cheers Arno -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic Menus in a PHP Form Issue
From: ak...@telkomsa.net To: aj...@alumni.iu.edu; php-general@lists.php.net Subject: RE: [PHP] Dynamic Menus in a PHP Form Issue Date: Tue, 25 May 2010 08:59:08 +0200 -Original Message- From: Alice Wei [mailto:aj...@alumni.iu.edu] Sent: 24 May 2010 04:47 PM To: php-general@lists.php.net Subject: [PHP] Dynamic Menus in a PHP Form Issue Hi,I have a snippet as in the following: ul liSelect the type of your starting point of interest:br/ div id=start_menuform action= name=form1 method=post spaninput type=radio value=Apartment name=start onclick=alert(document.form1.start)/ Apartment /span /form/div/li/ulIf I tried to put this at the top of a file where I save as PHP with other PHP execution statements, looks like the form does not do anything, and yet when I save the page as in HTML with out the other PHP execution, it works. I am trying to create a page where I have dynamic drop down menu lists so users can egenerate dynamic content based on their preference. Is it possible that I can save the entire file as a PHP and still keep the functionality, including generating dynamic menus, writing the proper entries to the database and printing out the proper output? Thanks for your help. Alice _ The reason it works in html is because it is executed in the browser. If you want this html to get to the browser you must either echo it to the output buffer that is sent to the browser, or end your php section with ? so that these lines are interpreted as part of the output that is sent to the browser. If your php script is running without error then I presume you're already doing this. If that's the case then maybe it's not being put into the output buffer the way you're expecting (e.g. maybe the quotes don't match). You can look at the source code in the browser and compare it against the working html code to see where the difference is. Cheers Arno Thanks, guys. I have set now to 2 different requests, and it is doing great now. Alice _ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2
[PHP] Dynamic Menus in a PHP Form Issue
Hi,I have a snippet as in the following: ul liSelect the type of your starting point of interest:br/ div id=start_menuform action= name=form1 method=post spaninput type=radio value=Apartment name=start onclick=alert(document.form1.start)/ Apartment /span /form/div/li/ulIf I tried to put this at the top of a file where I save as PHP with other PHP execution statements, looks like the form does not do anything, and yet when I save the page as in HTML with out the other PHP execution, it works. I am trying to create a page where I have dynamic drop down menu lists so users can egenerate dynamic content based on their preference. Is it possible that I can save the entire file as a PHP and still keep the functionality, including generating dynamic menus, writing the proper entries to the database and printing out the proper output? Thanks for your help. Alice _ The New Busy is not the old busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3
Re: [PHP] Dynamic Menus in a PHP Form Issue
At 10:46 AM -0400 5/24/10, Alice Wei wrote: Hi,I have a snippet as in the following: ul liSelect the type of your starting point of interest:br/ div id=start_menuform action= name=form1 method=post spaninput type=radio value=Apartment name=start onclick=alert(document.form1.start)/ Apartment /span /form/div/li/ulIf I tried to put this at the top of a file where I save as PHP with other PHP execution statements, looks like the form does not do anything, and yet when I save the page as in HTML with out the other PHP execution, it works. I am trying to create a page where I have dynamic drop down menu lists so users can egenerate dynamic content based on their preference. Is it possible that I can save the entire file as a PHP and still keep the functionality, including generating dynamic menus, writing the proper entries to the database and printing out the proper output? Thanks for your help. Alice Alice: I'm not sure as to what it is that you are asking, but php runs on the server and is done by time anyone looks at a select control. If you want a dynamic select, then there are two basic types: 1) dynamically generated on the server based upon what the user indicted via a previous submit; 2) dynamically generated on the client-side based upon what the user indicted via a javascript trigger. Now, please describe which type you want? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Menus in a PHP Form Issue
At 11:38 AM -0400 5/24/10, tedd wrote: At 10:46 AM -0400 5/24/10, Alice Wei wrote: Hi,I have a snippet as in the following: ul liSelect the type of your starting point of interest:br/ div id=start_menuform action= name=form1 method=post spaninput type=radio value=Apartment name=start onclick=alert(document.form1.start)/ Apartment /span /form/div/li/ulIf I tried to put this at the top of a file where I save as PHP with other PHP execution statements, looks like the form does not do anything, and yet when I save the page as in HTML with out the other PHP execution, it works. I am trying to create a page where I have dynamic drop down menu lists so users can egenerate dynamic content based on their preference. Is it possible that I can save the entire file as a PHP and still keep the functionality, including generating dynamic menus, writing the proper entries to the database and printing out the proper output? Thanks for your help. Alice Alice: I'm not sure as to what it is that you are asking, but php runs on the server and is done by time anyone looks at a select control. If you want a dynamic select, then there are two basic types: 1) dynamically generated on the server based upon what the user indicted via a previous submit; 2) dynamically generated on the client-side based upon what the user indicted via a javascript trigger. Now, please describe which type you want? Cheers, tedd -- Re the above, I meant indicated and not indicted -- sorry. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Form validation and save the form
-Original Message- From: aditya shukla [mailto:adityashukla1...@gmail.com] Sent: 11 January 2010 07:37 AM To: php-general Subject: [PHP] Form validation and save the form Hello Guys, I am trying to validate a form for user input , such that when something is missing load the form again by focusing on the wrong field.Say i don not enter my address so when the form loads everything else is saved and the form points to address field. Thanks Aditya You need Javascript for that not PHP. PHP is server side, javascript is client side (browser). Regards Angelo http://www.elemental.co.za http://www.wapit.co.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form validation and save the form
Angelo Zanetti wrote: -Original Message- From: aditya shukla [mailto:adityashukla1...@gmail.com] Sent: 11 January 2010 07:37 AM To: php-general Subject: [PHP] Form validation and save the form Hello Guys, I am trying to validate a form for user input , such that when something is missing load the form again by focusing on the wrong field.Say i don not enter my address so when the form loads everything else is saved and the form points to address field. Thanks Aditya You need Javascript for that not PHP. PHP is server side, javascript is client side (browser). He doesn't say anything about not reloading the form... in fact he explicitly says when something is missing load the form again. This suggests a server request and not JavaScript. Either way... validation can occur either in JavaScript or PHP... but it should ALWAYS occur in PHP regardless of any JavaScript validation. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form validation and save the form
Thanks for the reply guys.Do you guys know a good resource where i can read from about form validation through PHP.There a lot on google but please suggest something if you guys know. Thanks Aditya