Using a Submit Button to insert an entry into a MySQL database via PHP?
html, mysql, php, submit-button
Solution
Just set the `action` of the form to the URL of the script that performs the insert.
Note that since you are modifying a database, the request is probably non-idempotent and you should use the POST method.
<form action="/path/to/your/script.php" method="post">
<input type="submit">
</form>
Problem
I'm pretty new to PHP, so I'm not quite sure on what to do with this. Basically I'm trying to insert an entry into my MySQL database, through a "submit" button in HTML. I can't seem to get this to work, is it possible? ``` <?php include('db_connect.php'); $SQL = "INSERT INTO chosenitems (ID, Name, Price) VALUES ('', '4-6 Days', '£75.00')"; $result = mysql_query($SQL); ?> ``` The INSERT works perfectly fine on its own, but I want it to be executed when the "submit" button is pressed. Any help would be greatly appreciated. Thanks Tobo.