I'm trying to insert some data into a database using an html form. The form is coded in html, the database is managed using MySQL and I'm using php to insert data. I think the problem is not on the code but in the php set-up (I include the code just in case).
I've installed MAMP (I'm working on a Snow Leopard Mac). PHP seems to be working properly (If I enter commands on the terminal everything works fine)
The action of the form is a php file called insertar.php
The problem is that when I click on the submit button after filling the form, the browser shows the code for insertar.php but it doesn't insert.
I would greatly appreciate your help.
PHP CODE:
<?php
$conn = mysql_connect("localhost","root","root");
if (!$conn)
{
die('Imposible efectuar la conexion' . mysql_error());
}
mysql_select_db("zealot", $conn);
$id = $_POST["id"];
$date = $_POST["date"];
$name = $_POST["name"];
mysql_query("insert into logistica_rastreo values('$id' , '$date' , '$name');");
?>
HTML CODE
<form name="the_form" method="post" action="insertar.php">
<table>
id: <input type="text" size="30" maxlength="40" name="id"/>
date: <input type="text" size="30" maxlength="40" name="date"/>
name: <input type="text" size="30" maxlength="40" name="name"/>
</table>
<br/>
<input type="submit" value="Registrar" name="registrar" />
<br/>
</form>
insertar.php(which is type of PHP), than your server has not allowed PHP.$_POSTand using a manual insert inmysql_queryand it works!. I think the php file is correct. [By the way, this is the first php script that I'm running in this computer]<? phpinfo(); ?>, that executes? Andotherfile.phpwith contents<? die('test 123'); ?>does not?