Yes, I am a newbie. Could some kind person please take a look at the following code and let me know why the "Select" list item chosen does not insert into the database? All of the other form fields including "firstname", "lastname", etc. insert ok. It is only the selection from the "categories" list that does not insert. Why??
Here is the form (the processing script and script used to create the table are below):
<form action="orderconfirm.php" method="post">
<input type="hidden" name="username" value="<? print $_POST['username']?>">
<input type="hidden" name="password" value="<?print $_POST['password']?>">
<p align="left" class="latext">First Name:
<input name="firstname" type="text" id="firstname">
<br><br>
Last Name:
<input name="lastname" type="text" id="lastname">
<br><br>
E Mail Address:
<input name="email" type="text" id="email" size="55">
<br><br>
Website URL:
<input name="url" type="text" id="url" size="55">
<br><br>Number of links desired: <input name="linknum" type="int" id="linknum" size="2"></p>
<p align="left" class="latext">Select the category<br>
for your link(s)</p>
<p align="left" class="latext">
<select name="category" id="category">
<option value="Advertising & Marketing">Advertising & Marketing</option>
<option value="Agriculture & Forestry">Agriculture & Forestry</option>
<option value="Arts & Artists">Arts & Artists</option>
<option value="Automotive">Automotive</option>
<option value="Business and Financial Services">Business and Financial Services</option>
<option value="Business Opportunities">Business Opportunities</option>
<option value="Business to Business">Business to Business</option>
<option value="Computers & Internet">Computers & Internet</option>
<option value="Consumer Products and Services">Consumer Products and Services</option>
<option value="Education">Education</option>
<option value="Energy & Environment">Energy & Environment</option>
<option value="Food & Drink">Food & Drink</option>
<option value="Gaming">Gaming</option>
<option value="Health, Nutrition and Beauty">Health, Nutrition and Beauty</option>
<option value="Hobbies, Crafts, and Games">Hobbies, Crafts, and Games</option>
<option value="Home & Garden">Home & Garden</option>
<option value="Law">Law</option>
<option value="Managing & Consulting">Managing & Consulting</option>
<option value="Media & Entertainment">Media & Entertainment</option>
<option value="People">People</option>
<option value="Real Estate & Construction">Real Estate & Construction</option>
<option value="Security">Security</option>
<option value="Sports">Sports</option>
<option value="Talon">Talon</option>
<option value="Telecommunications">Telecommunications</option>
<option value="Transportation & Logistics">Transportation & Logistics</option>
<option value="Travel & Tourism">Travel & Tourism</option>
</select>
</p>
<div align="left" class="latext">Enter your link and descriptive text (2 short sentences max) here:<br>
<textarea name="link" cols="80" rows="5" id="describe"></textarea>
<br>
<input type="submit" name="Submit" value="Submit">
You will be taken to the Order Confirmation page. </div>
</form>
Here is the processing script:
<html><head><title>Linkdata Insert Record</title></head>
<body>
<?
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$url=$_POST['url'];
$linknum=$_POST['linknum'];
$category=$_POST['category'];
$link=$_POST['link'];
$linkedto=$_POST['linkedto'];
$linkedfrom=$_POST['linkedfrom'];
$linkedtoconf=$_POST['linkedtoconf'];
$linkedfromconf=$_POST['linkedfromconf'];
$maindate=$_POST['mainDate'];
$db="linkar";
$conn = mysql_connect("localhost","root","triadpass");
//$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
if (! $conn)Couldn't connect to MySQL");
mysql_select_db($db , $conn) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO linkar (firstname, lastname, email, url, linknum, category, link) VALUES ('$firstname','$lastname','$email','$url','$linknu m','$category','$link')")or die("Insert Error: ".mysql_error());
mysql_close($conn);
?>
<form method="POST" action="linkorder.php">
<input type="submit" value="Insert Another Record">
</form>
</body>
</html>
Here is the script used to create the table "linkdata":
<html><head><title> Create Link Data Table</title></head>
<body>
<?
$db="linkar";
$conn = mysql_connect("localhost","root","triadpass");
if (! $conn)
die("Couldn't connect to MySQL");
mysql_select_db($db , $conn)
or die("Select DB Error: ".mysql_error());
//create table
mysql_query("CREATE TABLE linkdata( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), firstname VARCHAR(55), lastname VARCHAR(55), email VARCHAR(55), url VARCHAR(55), linknum INT(5), category VARCHAR(55), link VARCHAR(255), linkedto VARCHAR(255), linkedfrom VARCHAR(255), linkedtoconf TINYINT(1), linkedfromconf TINYINT(1), mainDate VARCHAR(255))")or die("Create table Error: ".mysql_error());
mysql_close($conn);
?>
</body>
</html>