A simple website beater

Sorry for such an easy and simple question, but… Where can I see a simple example of driving information into a table that is stored in a database?

Example table, there are id text codecolumns. The codecolumn has only two values ​​- 1 or 2. Beater shape.

  • enter text(text entry form)
  • select code(select dropdown)

Thank you.


Answer 1, authority 100%

<form method='post' action='submitter.php'>
<input type='text' name='text'>
<select name='code'>
 <option value='1'>1</option>
 <option value='2'>2</option>
</select>
<input type='submit' value=''>
</form>

Here. And in the submitter.phpfile, the script for writing data to the database itself (do not forget about checking the data for correctness and security). The entered data itself will be in the variables $_POST['text']and $_POST['code'].


Answer 2

In submitter.phpwrite something like this:

$result = mysql_query ("INSERT INTO table (text,code) VALUES (".$_POST["name"].",".$_POST["code"].")");
if ($result == true) {
echo " "; }

Just don’t forget to connect to the database at the beginning, something like this : )

$dbuser = "";
$dbpass = "";
$dbname = " ";
$db = mysql_connect("localhost",$dbuser,$dbpass);
mysql_select_db($dbname,$db);