Help with a submit form
Posted: Thu Nov 10, 2005 12:17 pm
I am have a form file which is my index.php and the form is pointing to the newArticle.php. I don't get any errors, but no information is updated to the database. I know the connectino is there and i was able to upload using a test.php file?
Does anyone know what is wrong here? It should open a new php page and say echo added to the database?
Code: Select all
<form action="newArticle.php" method="POST">
<form name="form1" method="post" action="">
Resident Assistant's Name:
<input name="ranametxt" type="text" id="ranametxt">
</form>
<form name="form2" method="post" action="">
If Floater Enter Date:
<input name="floatertxt" type="text" id="floatertxt">
</form>
<form name="form3" method="post" action="">
If Weekend: From
<input name="weekendstarttxt" type="text" id="weekendstarttxt">
to
<input name="weekendendtxt" type="text" id="weekendendtxt">
</form>
<form name="form4" method="post" action="">
<input type="submit" />
</form>Code: Select all
<?php
// Get the PHP file containing the DbConnector class
require_once('../includes/DbConnector.php');
// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){
/
$connector = new DbConnector();
// Create an SQL query
$insertQuery = "INSERT INTO info (raname,floater,weekendstart,weekendend) VALUES (".
"'".$HTTP_POST_VARS['ranametxt']."', ".
"'".$HTTP_POST_VARS['floatertxt']."', ".
$HTTP_POST_VARS['weekendstarttxt'].", ".
"'".$HTTP_POST_VARS['weekendendtxt']."')";
// Save the form data into the database
if ($result = $connector->query($insertQuery)){
echo '<center><b>Article added to the database</b></center><br>';
}else{
exit('<center>Sorry, there was an error saving to the database</center>');
}
}
?>