View Single Post
Old 08-14-2007   #1 (permalink)
basicwe
Steven
 
Join Date: Jun 2005
Location: McAlester, OKlahaoma - United States
Posts: 21

Is something wrong?

Is there anything wrong with the code below assuming that there is nothing wrong with any of the included files? The problem is that the information will not submit itno the database, and the table's structure is fine.

PHP Code:
<?php
include ('include/config.php');
include (
'include/session.php');
$author $session->username;
$date date("M j, y");
if (isset(
$_POST['submitted'])) {
if (empty(
$_POST['title'])) {
echo 
'<p><font color="red">You need to enter a title.</font></p>';
} else {
$title $_POST['title'];
}
 
if (empty(
$_POST['category'])) {
echo 
'<p><font color="red">You need to enter a category.</font></p>';
} else {
$category $_POST['category'];
}
 
if (empty(
$_POST['question'])) {
echo 
'<p><font color="red">You need to enter a question.</font></p>';
} else {
$question $_POST['question'];
}
 
if (
$title && $category && question) {
$query "INSERT INTO questions (title, author, date, question, category) VALUES ('$title', '$author', '$date', '$queston', '$category')";
$result = @mysql_query($query);
 
if (
$result) {
echo 
'<p><font color="red">News was added!</font></p>';
} else {
echo 
'<font color="red"><p>News could not be added! Please try again.</p></font>';
}
} else {
echo 
'<p><font color="red">Please fill in the appropriate information</font></p>';
}
}
?>
 
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<p><b>News Title :</b><br />
<input type="input" name="title" size="25" maxlength="60" value="<?php if(isset($_POST['title'])) echo $_POST['title']; ?>" /></p>
 
<p><b>Name :</b><br />
<input type="input" name="category" size="15" maxlength="35" value="<?php if(isset($_POST['category'])) echo $_POST['category']; ?>" /></p>
 
<p><b>Message :</b><br />
 
<textarea rows="7" cols="55" name="question"><?php if(isset($_POST['question'])) echo $_POST['question']; ?></textarea></p>
 
<p><input type="submit" name="submit" value="Add News" /></p>
<input type="hidden" name="submitted" value="TRUE" /></p>
</form>
__________________
--
Steven

Last edited by basicwe; 08-14-2007 at 10:45 AM.
basicwe is offline