Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set-up php in order to insert data into a database?
    text
    copied!<p>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).</p> <p>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)</p> <p>The action of the form is a php file called <code>insertar.php</code></p> <p>The problem is that when I click on the submit button after filling the form, the browser shows the code for <code>insertar.php</code> but it doesn't insert.</p> <p>I would greatly appreciate your help.</p> <p><strong>PHP CODE:</strong></p> <pre><code>&lt;?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');"); ?&gt; </code></pre> <p><strong>HTML CODE</strong></p> <pre><code>&lt;form name="the_form" method="post" action="insertar.php"&gt; &lt;table&gt; id: &lt;input type="text" size="30" maxlength="40" name="id"/&gt; date: &lt;input type="text" size="30" maxlength="40" name="date"/&gt; name: &lt;input type="text" size="30" maxlength="40" name="name"/&gt; &lt;/table&gt; &lt;br/&gt; &lt;input type="submit" value="Registrar" name="registrar" /&gt; &lt;br/&gt; &lt;/form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload