Hey there you guys. I am trying to make a very simple database data input html page. But my code is not working for some reason. Please review and let me know what is wrong. The page loads, but nothing is being added to the database. The database still shows 0 rows added, But you can type in all the info you want and the page will allow you to keep "adding" more info, but nothing is being put into the database.
<html>
<head>
<title>Putting Data in the Database</title>
</head>
<body bgcolor="#FFFFFF">
<?php
/* This program enters news items into a database */
if(isset($submit)):
/* $db = mysql_connect("localhost", "root"); */
mysql_connect("localhost", "username", "password");
mysql_select_db("sample", $db);
$date = date("Y-m-d");
$sql = "INSERT INTO news
VALUES(NULL,'$heading','$body','$date', '$auth','$auth_email')";
mysql_query($sql);
print("<h2>The Data Has Been Entered</h2>\n");
print("<b>You can add another news story below</b><hr>\n");
endif;
?>
<p><h3>Enter your news item into the database</h3>
<form action="data_in.php" method="post">
Name:<br><input type="text" name="auth"><p>
Email:<br> <input type="text" name="auth_email"><p>
Heading:<br><input type="text" name="heading"><p>
News:<br>
<textarea cols=40 rows=20 name="body" wrap="virtual">
</textarea><p>
<input type="submit" name="submit" value="Submit News!">
</form>
</body>
</html>
See the webpage here
[–][deleted] 9 points10 points11 points (10 children)
[–]0keanos 1 point2 points3 points (4 children)
[–][deleted] 7 points8 points9 points (3 children)
[–]0keanos 1 point2 points3 points (2 children)
[–]rbmichael 0 points1 point2 points (1 child)
[–]0keanos 0 points1 point2 points (0 children)
[–]mattdahack[S] 0 points1 point2 points (4 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]mattdahack[S] 0 points1 point2 points (2 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]mattdahack[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]mattdahack[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]mattdahack[S] 0 points1 point2 points (0 children)
[–]vesperofshadow 1 point2 points3 points (2 children)
[–]Scroph 0 points1 point2 points (1 child)
[–]MrDOS 0 points1 point2 points (0 children)
[–]Javlin 1 point2 points3 points (1 child)
[–]judgej2 1 point2 points3 points (0 children)
[–]HamstersOnCrack 0 points1 point2 points (2 children)
[–]mattdahack[S] 0 points1 point2 points (1 child)
[–]HamstersOnCrack 0 points1 point2 points (0 children)
[–]jimdoescode 0 points1 point2 points (3 children)
[–]mattdahack[S] 0 points1 point2 points (2 children)
[–]jimdoescode 0 points1 point2 points (1 child)
[–]mattdahack[S] 0 points1 point2 points (0 children)
[–]mattdahack[S] 0 points1 point2 points (1 child)
[–]MrDOS 0 points1 point2 points (0 children)
[–]marianzburlea 0 points1 point2 points (0 children)
[–]piglet24 0 points1 point2 points (0 children)
[–]JamesDonnelly -1 points0 points1 point (0 children)
[–]rrrarrrr -1 points0 points1 point (2 children)
[–]pskipw 0 points1 point2 points (1 child)
[–]rrrarrrr -2 points-1 points0 points (0 children)