Jump to content

darrenfinch

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

darrenfinch's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Andy, Am using Abyss web server form is .html file parsing into handler1.php I found the error (just), the book is incorrect! (rather embaraased that I did not spot it sooner!) The form uses $_POST to post the info on the server, and php script was also using the $_POST method (i..e not $_GET) this works now, and I can go home happy! Many thanks [!--quoteo(post=353629:date=Mar 10 2006, 09:59 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Mar 10 2006, 09:59 AM) [snapback]353629[/snapback][/div][div class=\'quotemain\'][!--quotec--] Two questions: #1 - are you actually saving your work as a .php file rather than as a .html file? #2 - are you testing this on a live server or just in some editor preview mode? [/quote]
  2. Also, I just tried viewing the page source; all I get is the HTML! i.e. <html> ... <body> Name Value </tr></table></html></body> It is ignoring everything after the foreach() even if I put a print"hello world"; after the foreach() it will not display hello world This is crazy! [!--quoteo(post=353574:date=Mar 10 2006, 05:20 AM:name=DarrenFinch)--][div class=\'quotetop\']QUOTE(DarrenFinch @ Mar 10 2006, 05:20 AM) [snapback]353574[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi, I know I should find some more up to date material - but getting this problems is one way of REALLY understanding the code! I have been following PHP 4 weekend crash course, and I cannot for the life of me get this to work. If I create a form and $_POST to say handler.php handler.php contains <?php phpinfo() ?> // this works - if I scroll down to the variables I can see all the input from the form however, if I change the form to $_POST to handler1.php, which contains <?php //Generic form data parser // Begin HTML page and field table echo "<html><head><title>Check Form</title></head><body><table cellpadding=20 border=1>"; echo "<tr><td><b>Name</b></td><td><b>Value</b></td></tr>"; // For each $_POST value foreach ($_POST as $key => $value) { // Print the key in the first column print "<tr><td>" . $key . "&nbsp; </td>\n"; print "<td>"; // If the field is an empty array, parse it if (is_array($value)) { foreach ($value as $selkey => $selvalue) { print $selkey . " : ". $selvalue ."&nbsp; <br />";} } else { // Else (not array) just print the value // in second column print $value . "&nbsp;"; } print "</td></tr>\n"; } print "</table></body></html>"; ?> All I get is the HTML header Can anyone help please ? [/quote]
  3. I thought with PHP 5 you were supposed to use the superglobal variables ? I found with other forms I have had to use $_POST in all cases (POST returns blanks) i.e. POST becomes $_POST I tried it without the $_ and I still get the same and if I use the same method ($_POST) with the phpinfo () I see the variables, so I assume that the form input is correct but somehow the variables are not being passed/parsed correctly in the handler1.php script but I cannot see why! I dont think it is the web server either (everything else I have thrown at it works great) [!--quoteo(post=353576:date=Mar 10 2006, 05:26 AM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 05:26 AM) [snapback]353576[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] <?php //Generic form data parser // Begin HTML page and field table echo "<html><head><title>Check Form</title></head><body><table cellpadding=20 border=1>"; echo "<tr><td><b>Name</b></td><td><b>Value</b></td></tr>"; // For each $_POST value foreach ($_POST as $key => $value) { // Print the key in the first column     print "<tr><td>" . $key . "&nbsp; </td>\n";     print "<td>";          // If the field is an empty array, parse it     if (is_array($value))     {         foreach ($value as $selkey => $selvalue)         {             print $selkey . " : ". $selvalue ."&nbsp; <br />";         }     }     else     {         // Else (not array) just print the value         // in second column         print $value . "&nbsp;";     } print "</td></tr>\n"; } print "</table></body></html>"; ?> [/code] worked absolutely fine for me. try placing [code] <form method='post'> <input type='text' name='test1' /><br /> <Input type='text' name='test2' /><br /> <input type='text' name='test3' /><br /> <input type='submit'> </form> [/code] directly under the handler in handler1.php load the page up and fill out the form. If you get it OK from there something's going wrong between your form and the handler page. Have you definitely set the action to the correct handler? [/quote]
  4. Hi, I know I should find some more up to date material - but getting this problems is one way of REALLY understanding the code! I have been following PHP 4 weekend crash course, and I cannot for the life of me get this to work. If I create a form and $_POST to say handler.php handler.php contains <?php phpinfo() ?> // this works - if I scroll down to the variables I can see all the input from the form however, if I change the form to $_POST to handler1.php, which contains <?php //Generic form data parser // Begin HTML page and field table echo "<html><head><title>Check Form</title></head><body><table cellpadding=20 border=1>"; echo "<tr><td><b>Name</b></td><td><b>Value</b></td></tr>"; // For each $_POST value foreach ($_POST as $key => $value) { // Print the key in the first column print "<tr><td>" . $key . "&nbsp; </td>\n"; print "<td>"; // If the field is an empty array, parse it if (is_array($value)) { foreach ($value as $selkey => $selvalue) { print $selkey . " : ". $selvalue ."&nbsp; <br />";} } else { // Else (not array) just print the value // in second column print $value . "&nbsp;"; } print "</td></tr>\n"; } print "</table></body></html>"; ?> All I get is the HTML header Can anyone help please ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.