Greetings, I have been attempting to make a drop down menu of countries. From this menu I wish to create a variable in order to INPUT into mysql database. I have no trouble making the drop down menu, but I am unable to store a variable for it.
Here is a rough copy of what I am making:
<html>
<head>
<title>Add New MySQL User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
if(isset($_POST['add']))
{
include 'c:\sokkit\conf ig.php';
include 'c:\sokkit\open db.php';
$username = $_POST['username'];
$password = $_POST['password'];
$query = "INSERT INTO account (username, password, location) VALUES ('$username', '$password', '$country')";
mysql_query($qu ery) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($qu ery) or die('Error, insert query failed');
include 'c:\sokkit\clos edb.php';
echo "New MySQL user added";
}
else
{
?>
<form name="myform" action="http://www.mydomain.co m/myformhandler.c gi" method="POST">
<div align="left">
<select name="mydropdow n">
<option value="Milk">Fr esh Milk</option>
<option value="Cheese"> Old Cheese</option>
<option value="Bread">H ot Bread</option>
</select>
</div>
</form>
<form method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2" >
<tr>
<td width="100">Use rname</td>
<td><input name="username" type="text" id="username"> </td>
</tr>
<tr>
<td width="100">Pas sword</td>
<td><input name="password" type="text" id="password"> </td>
</tr>
<tr>
<td width="100">&nb sp;</td>
<td> </td>
</tr>
<tr>
<td width="100">&nb sp;</td>
<td><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>
As you can see my mysql Insert command here:
$query = "INSERT INTO account (username, password, location) VALUES ('$username', '$password', '$country')";
I set it using the variable $country. But i have no way to store the variable from here:
<div align="left">
<select name="mydropdow n">
<option value="Milk">Fr esh Milk</option>
<option value="Cheese"> Old Cheese</option>
<option value="Bread">H ot Bread</option>
</select>
</div>
If someone could assist me in creating a stored variable from this drop down menu in order to INSERT into mysql database I would greatly appreciate it.
This is the return error when php script is run.
Notice: Undefined variable: country in C:\sokkit\site\ Accounts\dummy. php on line 17
New MySQL user added
Here is a rough copy of what I am making:
<html>
<head>
<title>Add New MySQL User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
if(isset($_POST['add']))
{
include 'c:\sokkit\conf ig.php';
include 'c:\sokkit\open db.php';
$username = $_POST['username'];
$password = $_POST['password'];
$query = "INSERT INTO account (username, password, location) VALUES ('$username', '$password', '$country')";
mysql_query($qu ery) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($qu ery) or die('Error, insert query failed');
include 'c:\sokkit\clos edb.php';
echo "New MySQL user added";
}
else
{
?>
<form name="myform" action="http://www.mydomain.co m/myformhandler.c gi" method="POST">
<div align="left">
<select name="mydropdow n">
<option value="Milk">Fr esh Milk</option>
<option value="Cheese"> Old Cheese</option>
<option value="Bread">H ot Bread</option>
</select>
</div>
</form>
<form method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2" >
<tr>
<td width="100">Use rname</td>
<td><input name="username" type="text" id="username"> </td>
</tr>
<tr>
<td width="100">Pas sword</td>
<td><input name="password" type="text" id="password"> </td>
</tr>
<tr>
<td width="100">&nb sp;</td>
<td> </td>
</tr>
<tr>
<td width="100">&nb sp;</td>
<td><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>
As you can see my mysql Insert command here:
$query = "INSERT INTO account (username, password, location) VALUES ('$username', '$password', '$country')";
I set it using the variable $country. But i have no way to store the variable from here:
<div align="left">
<select name="mydropdow n">
<option value="Milk">Fr esh Milk</option>
<option value="Cheese"> Old Cheese</option>
<option value="Bread">H ot Bread</option>
</select>
</div>
If someone could assist me in creating a stored variable from this drop down menu in order to INSERT into mysql database I would greatly appreciate it.
This is the return error when php script is run.
Notice: Undefined variable: country in C:\sokkit\site\ Accounts\dummy. php on line 17
New MySQL user added
Comment