Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are trying to access to the POST data, so you should do something like that :</p> <p>EDIT: be careful about the data you put into your database. You should use a modern database API, or, at least, escape your data (cf bellow code)</p> <pre><code>&lt;form action="insert.php" method="post"&gt; Name: &lt;input type="text" name="name"&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; &lt;?php // Following code will be called if you submit your form if (!empty($_POST['name'])) : // This is the connection to my database $con = mysql_connect('127.0.0.1', 'shane', 'diamond89'); if (!$con){ die('Could not Connect: ' . mysql_error()); } // This creates my table layout echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Delete&lt;/th&gt; &lt;/tr&gt;"; // This selects which database i want to connect to $selected = mysql_select_db("shane",$con); if (!$con){ die("Could not select examples"); } // This inserts new information to the Database $query = "INSERT INTO test1 VALUES('id', \'".mysql_real_escape_string($_POST['name'])."\')"; $result = mysql_query($query); if ($result){ echo("Input data is Successful"); }else{ echo("Input data failed"); } // This chooses which results i want to select from $result = mysql_query("SELECT `id`, `name` FROM `test1` WHERE 1"); // This outputs the information into my table while ($row = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['id'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['name'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . "[D]" . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; // This closes my connection mysql_close($con); endif; ?&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