Forum Moderators: coopster
I'm new to PhP, but I find it fascinating! Can you please check my scripts and forms and let me know what I am doing wrong? I'm trying to let visitors to the website, submit comments and news articles. When I submit/add a comment or article, the "add_article.php"
page has the results below.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
Article Entered. print "
"; print "
You Just Entered This Information Into the Database
"; print "Title : $article_title
Author : $author_name
Date: $date_created
Content: $content
URL: $URL
";?>
It displays the headings and fields, but not the data I entered. When I check the database, only the "ID" field increased from 4 to 11. The other fields for the data entered were empty.
Please check the codes. I do have problems with when and where to use double quotes, single quotes, etc..
The html and php codes are below.
Thanks in Advance for your help,
Senmar
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
ADD_ARTICLE.PHP
<?php
$db = mysql_connect("localhost","0","ok");
mysql_select_db ("News_Articles");
$query = "INSERT INTO ccds_news(article_title, author_name, date_created, content, url)
VALUES('".$_POST['$artitle_title']."','".$_POST['$author_name']."','".$_POST['$date_created'] ."','".$_POST['$content']."','".$_POST['$url']."' )";
$result = mysql_query($query);
echo 'Article Entered.';
mysql_close();
?>
print "<HTML><TITLE>Article Added</TITLE><BODY
BGCOLOR=\"#FFFFFF\"><center><table border=\"0\"
width=\"500\"><tr><td>";
print "<p><font face=\"verdana\" size=\"+0\"> <center>You
Just Entered This Information Into the
Database<p><blockquote>";
print "Title : $article_title</p>
<p>Author : $author_name</p>
<p>Date: $date_created</p>
<p>Content: $content</p>
<p>URL: $URL</p></blockquote></td></tr></table>
</center>
</BODY></HTML>";
?>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
Form.html
<form name="ccds_news" action="add_article.php">
<input type="hidden" name="id" value="null">
<tr><td align="left">Article Title</td>
<td>
<input type="text" name="Article Title" size="50"></td>
</tr>
<tr><td align="left">Author Name</td>
<td><input type="text" name="Author Name" size="30"></td>
</tr>
<tr><td align="left">Date</td>
<td><input type="text" name="date_created" size="12"></td>
</tr>
<tr><td align="left">Content:</td>
<td><textarea name="content" cols="50" rows="10"></textarea>
</td></tr>
<tr><td align="left">URL</td>
<td><input type="text" name="url" size="50"></td>
</tr><tr><td colspan="2">
<input type="submit" value="Submit Article">
</td>
</tr></form>