The Student Room Group
Reply 1
Saying for example you have a form:

<form method="post" action="script.php">
<p>Name: <input type="text" name="name"></p>
<p><input type="submit" value="Submit"></p>
</form>


A very simple PHP example to insert the name into a db would be:

<?php

// check that we have received data
if(!empty($_POST))
{
// get and clean data input
$name = mysql_real_escape_string($_POST['name']);

// insert into db
$sql = mysql_query("INSERT INTO dbname (name) VALUES('".$name."')");

// output success or error
if($sql) { echo "<p>Success.</p>"; } else { echo "Error."; }
}

?>


Hope that helps :smile:

Latest

Trending

Trending