Select-Menu Wert in Tabelle eintragen



Mittels INSERT-Anweisung lassen sich die Daten eines SELECT-Menues in eine Tabelle eintragen.


<html>
<head>
</head>
<body>

<form method=post action=insert.php>
<select name="name">
<option value="mueller">Müller</option>
<option value="meyer" selected="selected">Meyer</option>
<option value="miller">Miller</option>
</select>
<input type=submit>
</form>

<?php

$servername = "yourservername";
$username = "yourusername";
$password = "yourpassword";
$dbname = "yourdbname";

$name=$_POST['name'];

$con = mysqli_connect($servername,$username,$password,$dbname);

$res = mysqli_query($con, "INSERT INTO data (name) VALUES ('$name')");

$num = mysqli_num_rows($res);

mysqli_close($con);

?>

</body>
</html>



created by NETTECS.ch