Strange things are happening.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adrigen
Forum Newbie
Posts: 9
Joined: Tue Oct 07, 2003 3:32 am
Contact:

Strange things are happening.

Post by adrigen »

I'm just starting out with php, and following a tutorial. After LOTS of heart ache i have decided PHP is not behaving the way it should:

On a page of HTML that has three snippets of PHP, the HTML code between the second and third PHP blocks is not visible in the browser.

Code: Select all

<html>

<body>

<?php



if (submit) &#123;

  // process form

  while (list($name, $value) = each($HTTP_POST_VARS)) &#123;

    echo "$name = $value<br>\n";

  &#125;

&#125; else&#123;

  // display form

  ?>

  <form method="post" action="<?php echo $PHP_SELF?>">

  First name:<input type="Text" name="first"><br>

  Last name:<input type="Text" name="last"><br>

  Address:<input type="Text" name="address"><br>

  Position:<input type="Text" name="position">
  y <br>

  <input type="Submit" name="submit" value="Enter information">

  </form>

  <?php



&#125; // end if



?>



</body>



</html>
This page appears as:

Code: Select all

<html>

<body>




</body>



</html>
Any ideas?
Greatly appreciated,
Adrian
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try this version (it's just your version 'tidied' up, but you need to get a new book ;)):

Code: Select all

<html>
<body>
<?php
error_reporting(E_ALL);
if (!empty($_POST['submit'])) {
  // process form
  while (list($name, $value) = each($_POST)) {
    echo "$name = $value<br>\n";
  }
} else{
  // display form
?>
  <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  First name:<input type="Text" name="first"><br>
  Last name:<input type="Text" name="last"><br>
  Address:<input type="Text" name="address"><br>
  Position:<input type="Text" name="position">
  y <br>
  <input type="Submit" name="submit" value="Enter information">
  </form>
<?php
} // end if
?>
</body>
</html>
adrigen
Forum Newbie
Posts: 9
Joined: Tue Oct 07, 2003 3:32 am
Contact:

Post by adrigen »

WOW thanks.
I was using the WEBMONKEY tutorial. I won't any more :)
Can you suggest a good online PHP + MySQL tutorial?
Thanks
Adrian
Post Reply