PHP - HandleForm.php not working [T_Variable Error
Posted: Sun Feb 01, 2004 12:57 pm
Hello,
Im making a simple news publishing deal, for my site...
Now, Ive made the Form.html
(So a user can fill it out, then hit submit)
Ive also made the next page 'handleform.php'
Ive provided the code for HandleForm.php below, and form.html...
Form.html, you shouldn't have too look at, I just threw it in there..
However, my question is this:
When I go to the form.html, fill it out, and hit submit, it gives me this error:
Parse error: parse error, unexpected T_VARIABLE in c:\program files\apache group\apache\htdocs\handleform.php on line 19
And Im not sure why it's giving me that error, because I read thru the code, and I found an error, but I did fix it, however, it didn't fix the error...
And just a tip, I have know db_username, or db_password
for any of my Databases...just so you guys know when you see it in the code.
_________________________________________________________
Here is the code for HandleForm.php
<html>
<head>
<Title>Inserting Data</title>
<body>
<?php
/* This page recieves and handles th e data
generated by "form.html". */
// Trim the incoming data.
$Array["FirstName"] = trim
($Array["FirstName"]);
$Array["LastName"] = trim
($Array["LastName"]);
$Array["Email"] = trim
($Array["Email"]);
$Array["Comments"] = trim
($Array["Comments"]);
$Host = "localhost"
$DBName = "New";
$TableName = "Feedback";
$Link = mysql_Connect ($localhost);
$Query = "INSERT into $TableName values
('0', '$Array[FirstName]',
'Array[LastName', 'Array[Email]',
'$Array[Comments]')";
print ("The query is:<BR>$Query<P>\n");
if (mysql_db_query($DBName, $Query,
$Link)) {
print ("The query was successfully
executed!<BR>\n");
} else {
print ("The query could not be
executed<BR>\n");
}
mysql_close($Link);
?>
</body>
</html>
___________________________________________________________
Here is the code for form.html
<HTML>
<HEAD>
<TITLE>HTML Form</title>
</HEAD>
<BODY>
<FORM ACTION="HandleForm.php" METHOD=POST>
First Name <INPUT TYPE=TEXT NAME="Array[FirstName]" SIZE=20><BR>
Last Name <INPUT TYPE=TEXT NAME="Array[LastName]" SIZE=40><BR>
Email Address <INPUT TYPE=TEXT NAME="Array[Email]" SIZE=60><BR>
Comments <TEXTAREA NAME="Array[Comments]" ROWS=5 COLS=40<TEXTAREA></textarea><br>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="SUBMIT!">
</FORM>
</BODY>
</HTML>
Im making a simple news publishing deal, for my site...
Now, Ive made the Form.html
(So a user can fill it out, then hit submit)
Ive also made the next page 'handleform.php'
Ive provided the code for HandleForm.php below, and form.html...
Form.html, you shouldn't have too look at, I just threw it in there..
However, my question is this:
When I go to the form.html, fill it out, and hit submit, it gives me this error:
Parse error: parse error, unexpected T_VARIABLE in c:\program files\apache group\apache\htdocs\handleform.php on line 19
And Im not sure why it's giving me that error, because I read thru the code, and I found an error, but I did fix it, however, it didn't fix the error...
And just a tip, I have know db_username, or db_password
for any of my Databases...just so you guys know when you see it in the code.
_________________________________________________________
Here is the code for HandleForm.php
<html>
<head>
<Title>Inserting Data</title>
<body>
<?php
/* This page recieves and handles th e data
generated by "form.html". */
// Trim the incoming data.
$Array["FirstName"] = trim
($Array["FirstName"]);
$Array["LastName"] = trim
($Array["LastName"]);
$Array["Email"] = trim
($Array["Email"]);
$Array["Comments"] = trim
($Array["Comments"]);
$Host = "localhost"
$DBName = "New";
$TableName = "Feedback";
$Link = mysql_Connect ($localhost);
$Query = "INSERT into $TableName values
('0', '$Array[FirstName]',
'Array[LastName', 'Array[Email]',
'$Array[Comments]')";
print ("The query is:<BR>$Query<P>\n");
if (mysql_db_query($DBName, $Query,
$Link)) {
print ("The query was successfully
executed!<BR>\n");
} else {
print ("The query could not be
executed<BR>\n");
}
mysql_close($Link);
?>
</body>
</html>
___________________________________________________________
Here is the code for form.html
<HTML>
<HEAD>
<TITLE>HTML Form</title>
</HEAD>
<BODY>
<FORM ACTION="HandleForm.php" METHOD=POST>
First Name <INPUT TYPE=TEXT NAME="Array[FirstName]" SIZE=20><BR>
Last Name <INPUT TYPE=TEXT NAME="Array[LastName]" SIZE=40><BR>
Email Address <INPUT TYPE=TEXT NAME="Array[Email]" SIZE=60><BR>
Comments <TEXTAREA NAME="Array[Comments]" ROWS=5 COLS=40<TEXTAREA></textarea><br>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="SUBMIT!">
</FORM>
</BODY>
</HTML>