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
adrigen
Forum Newbie
Posts: 9 Joined: Tue Oct 07, 2003 3:32 am
Contact:
Post
by adrigen » Wed Jun 30, 2004 9:09 am
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) {
// process form
while (list($name, $value) = each($HTTP_POST_VARS)) {
echo "$name = $value<br>\n";
}
} else{
// 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
} // end if
?>
</body>
</html>
This page appears as:
Any ideas?
Greatly appreciated,
Adrian
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Wed Jun 30, 2004 9:16 am
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 » Wed Jun 30, 2004 9:24 am
WOW thanks.
I was using the WEBMONKEY tutorial. I won't any more
Can you suggest a good online PHP + MySQL tutorial?
Thanks
Adrian