i have a php page where i am listing all usernames from db to a dropdown. Now i need to select a name and need to add to another table in datbase.
Listing from db I was able to do. but stuck how to add the selected value back to another db. Please help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Member page</title>
</head>
<a href="logout.php">Logout</a>
<input name="submit" type="submit" value="Submit"/>
<body>
<?php
session_start();
include('configdb.php');
if($_SESSION['user_name'] == '')
{
header("Location: index.php");
exit;
}
echo "Hi ".$_SESSION['user_name'];
$query = "SELECT username FROM user";
$result = mysqli_query($mysqli,$query) or die(mysqli_error($mysqli));
$dropdown = "<select name='user'>";
while($row = mysqli_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['username']}'>{$row['username']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>
</body>
</html>
Try this code :- [ UPDATED CODE]