I’m trying to code a simple form to enter some values into a database, but I just can’t get the form and the database to talk to one another. Every time I test the form, it just takes me back to the same page, without the error or success message I’ve set up, and the value doesn’t get entered into the database.
Here’s what I’ve got:
[php]<?php
if (isset($_POST[‘submit’])) {
$number = htmlspecialchars(strip_tags($_POST[‘number’]));
mysql_connect('localhost', 'root');
mysql_select_db('progressbar');
$sql = "INSERT INTO progressbar (number) VALUES ('$number')";
$result = mysql_query($sql) or print ("Something went horribly wrong here. Sorry.<br />" . $sql . "<br />" . mysql_error());
if ($result != false) {
print ("<p>SUCCESS!</p>");
}
mysql_close();
}
?>
What's your number?