I have the simplest database entry that when I hit “submit”, it takes me to my home directory and nothing is added to the database. How do I fix it so it inputs the data? I haven’t had any problems like this in the past using the same code…
<?php
if(isset($_POST['submit'])) {
$text = $_POST['text'];
$link = mysql_connect("localhost", "******", "********") or die("Couldn't make connection.");
@mysql_select_db("*****") or die("Couldn't select database");
mysql_query("INSERT INTO wall (message) VALUES ('$text')");
}
?>
<html>
<form action="post" name="post" id="post">
<input type="text" id="text" name="text"/>
<input type="submit" name="submit" id="submit" value="submit"/>
</form>
</html>
I know my password and database name are correct, because when I take away the “form” and “isset”, it uploads no problem every time I reload the page:
<?php
$link = mysql_connect("localhost", "******", "*******") or die("Couldn't make connection.");
@mysql_select_db("********") or die("Couldn't select database");
mysql_query("INSERT INTO wall (message) VALUES ('test')");
?>
change
to
Action is the page you want the form to submit to
Method is the type (which defaults to get)