Forms-PHP-and-errors
| From: | jh | Date: | Tue, 08 Jul 2003 17:59:49 +0000 |
| Subject: | Forms-PHP-and-errors | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-20736@lists.php.net to get a copy of this message | ||
Hi,
I am new to PHP and I am somewhat frustrated at times, because I am having a similar problem to
Sebastian Baran, with Webserver4Everyone and PHP 4.2.3. under Win95
I would be grateful if anyone can throw some light on the problem, before I give up on php.
Find below the code for the form and script and the errors which it outputs.
Thanks
jh
---------------------------------This is the form-------------------------------------
<HTML>
<HEAD>
<TITLE>Project 6-2</TITLE>
</HEAD>
<BODY bgcolor="#00ddff">
<!-- File p-6-2.html -->
<FORM METHOD="POST" ACTION="p-6-2.php">
<H1>Contact Information</H1>
<TABLE>
<TR>
<TD>Title:</TD>
<TD><INPUT TYPE="TEXT" NAME="title"></TD>
</TR>
<TR>
<TD><B>First Name:</B></TD>
<TD><INPUT TYPE="TEXT" NAME="firstname"></TD>
</TR>
<TR>
<TD>Middle Name:</TD>
<TD><INPUT TYPE="TEXT" NAME="middlename"></TD>
</TR>
<TR>
<TD><B>Last Name:</B></TD>
<TD><INPUT TYPE="TEXT" NAME="lastname"></TD>
</TR>
</TR>
</TABLE>
<BR>
<BR>
<BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<BR>
<BR>
<INPUT TYPE="RESET" VALUE="Clear the Form">
</FORM>
</BODY>
</HTML>
-----------------------This the PHP script------------------------------
<HTML>
<HEAD>
<TITLE>Project 6-2</TITLE>
</HEAD>
<BODY bgcolor="#ffbbf0>
<!-- File p-6-2.php -->
<?php
$errors=0;
if (!trim($title))
{
echo "<BR><B>Title</B> is required.";
$errors++;
}
if (!trim($firstname))
{
echo "<BR><B>First name</B> is required.";
$errors++;
}
if (!trim($lastname))
{
echo "<BR><B>Last name</B> is required.";
$errors++;
}
if ($errors > 0)
echo "<BR><BR><BR>Please use your browser's back button " .
"to return to the form, correct ";
if ($errors == 1)
echo "the error, ";
if ($errors > 1)
echo "the errors, ";
if ($errors > 0)
echo "and re-submit the form.";
?>
</BODY>
</HTML>
------------------------These are the error messages it outputs-------------------------------
Notice: Undefined variable: title in D:\web\myforms\p-6-2.php on line 11
Title is required.
Notice: Undefined variable: firstname in D:\web\myforms\p-6-2.php on line 17
First name is required.
Notice: Undefined variable: lastname in D:\web\myforms\p-6-2.php on line 23
Last name is required.
Please use your browser's back button to return to the form, correct the errors, and re-submit
the form.
----------------------------------------------------------------------------------------------