I have installed PHP and Apache on my WINXP notebook. I configured apache to load PHP as module.
I installed Dev-PHP IDE to write PHP code. I wrote a simple PHP/HTML page as per a book I am reading, nothing works.
OK, I've seen many cases where code printed on books do not work - I've spend a number of hours playing with this "very" simple, but it is kicking my behind, program and I cannot get it to work.
Now the questions:
Q. How do I make sure PHP engine is running?
Q. What is wrong with this code?
As you can see, it just does not get simpler than this (I can do this in my sleep in ColdFusion). Three very basic steps:
1. Get input
2. Validate input
3. Show input on screen
I think that the problem is with PHP Engine not running or not properly configured (I rather admit to that than being beaten by the above posted code).
Your help will be greatly appreciated.
Regards,
Jose Lerebours
KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
I installed Dev-PHP IDE to write PHP code. I wrote a simple PHP/HTML page as per a book I am reading, nothing works.
OK, I've seen many cases where code printed on books do not work - I've spend a number of hours playing with this "very" simple, but it is kicking my behind, program and I cannot get it to work.
Now the questions:
Q. How do I make sure PHP engine is running?
Q. What is wrong with this code?
Code:
<html>
<head>
<title>Contact Info Checker</title>
</head>
<body bgcolor="#FFFFFF">
<?PHP
/* Declare some functions */
function print_form($ff_fname, $ff_lname, $ff_email, $ff_zip, $ff_os)
{
?>
<form action="/form_checker.php" method="post">
<table cellspacing="2" cellpadding="2" border="1">
<tr>
<td>First Name</td>
<td><input type="text" name="ff_fname" value="<?php print($ff_fname); ?>"></td>
</tr>
<tr>
<td>Last Name<b>*</b></td>
<td><input type="text" name="ff_lname" value="<?php print($ff_lname); ?>"></td>
</tr>
<tr>
<td>eMail Address<b>*</b></td>
<td><input type="text" name="ff_email" value="<?php print($ff_email); ?>"></td>
</tr>
<tr>
<td>Zip Code<b>*</b></td>
<td><input type="text" name="ff_zip" value="<?php print($ff_zip); ?>"></td>
</tr>
<tr>
<td>Operating System</td>
<td><input type="text" name="ff_os" value="<?php print($ff_os); ?>"></td>
</tr>
</table>
<input type="submit" name="ff_submit" value="Submit!">
<input type="reset">
</form>
<?PHP
} /* EOF - PrintForm() */
function check_form($ff_fname, $ff_lname, $ff_email, $ff_zip, $ff_os)
{
if(!isset($_POST['ff_lname']) || !isset($_POST['ff_email']) || !isset($_POST['ff_zip'])):
print("<h3>You are missing some required fields!</h3>");
if(!isset($_POST['ff_lname']))
{
print("You need to fill in your <b>Last Name</b>.<br>");
}
if(!isset($_POST['ff_email']) || $ff_email == "")
{
print("You need to fill in your <b>eMail Address</b>.<br>");
}
if(!isset($_POST['ff_zip']))
{
print("You need to fill in your <b>Zip Code</b>.<br>");
}
print_form($ff_fname, $ff_lname, $ff_email, $ff_zip, $ff_os);
else:
confirm_form($ff_fname, $ff_lname, $ff_email, $ff_zip, $ff_os);
endif;
} /* EOF check_form() */
function confirm_form($ff_fname, $ff_lname, $ff_email, $ff_zip, $ff_os)
{
?>
<h2>Thanks! Below is the information you sent us.</h2>
<p><b>Contact Info</b>
<?PHP
print '<br>$ff_fname $ff_lname<br>$ff_email<br>Zip: $ff_zip<br>OS: $ff_os\n';
}
/* Begin Main Program */
if(!isset($_POST['ff_submit'])):
?>
<h3>Please enter your information</h3>
Fields with a "<b>*</b>" are required.<p>
<?PHP
print_form("","","","","");
else:
check_form($ff_fname, $ff_lname, $ff_email, $ff_zip, $ff_os);
endif;
?>
</body>
</html>
As you can see, it just does not get simpler than this (I can do this in my sleep in ColdFusion). Three very basic steps:
1. Get input
2. Validate input
3. Show input on screen
I think that the problem is with PHP Engine not running or not properly configured (I rather admit to that than being beaten by the above posted code).
Your help will be greatly appreciated.
Regards,
Jose Lerebours
KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours