I've asked this question a few years ago but lost the script, so I know it can be done.
I have a contact form or add page form, using this example:
existing dropdown list (countries)
I need next to the existing dropdown list, text input box, then a add button (add your country if not listed)
then it shows in existing dropdown list after refreshing the page.
// connect to database
$connection = mysql_connect($host, $username, $password) or die ("Unable to connect!");
<table border="0" cellspacing="0" cellpadding="0" colspan="2">
<form action="<? echo $PHP_SELF; ?>" method="POST">
// get country list
$query = "SELECT id, country from countries";
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
while (list($id, $country) = mysql_fetch_row($result))
echo "<option value=$id>$country</option>";
<td>Add Country if not listed</td>
<td><input type="text" name="country" size="25"></td>
<td><input type=submit name=submit value="Add Country"></td>
I would appreciate all the help. Thank you.