I have 2 tables inside of my database and 2 forms on my website. 1 form works and sends information over to its table in the database while the other form doesn't although I have used the exact same method for both.
Here is my code, please help me find out why information isn't being send over to its table in the database.
NOTE: I have a login system and when I send this form over I'm currently logged in.
The form
<form action = "order.php" method = "post">
<b>Warranty:</b> </br>
<select name="warranty">
<option value="0" class="registerFields">No Warranty</option>
<option value="1" class="registerFields">1 Year</option>
<option value="2" class="registerFields">2 Years</option>
</select> </br>
<b>Delivery:</b> </br>
<select name="delivery">
<option value="first" class="registerFields">1st Class</option>
<option value="second" class="registerFields">2nd Class</option>
<option value="recorded" class="registerFields">Recorded & Signed</option>
</select> </br>
<b>Price:</b> </br>
<select name="price">
<option value="price" class="registerFields">£159</option>
</select> </br>
<input type="submit" value="Complete Order" class="registerSubmit" />
</form>
The order.php page which sends the form information over to the database
<?php
//create the connection between the form and the server
include('connectFileProject.php'); //file that connects website to server & database
//insert form information into the database
$sql = "INSERT INTO order SET username='$username', warranty='$warranty', delivery='$delivery', price='$price'";
$result = mysql_query($sql); //perform the action
if($result){
echo "Congratulations, your order is now live.";
}
else{
echo "There was an error";
}
?>
<html>
<body>
<br />
<br />
<a href="kaahh.php">Go back</a>
</body>
</html>
The order table has the following fields:
ID
username
warranty
delivery
price
NOTE 2: Since I'm already logged in, I assume that my username will be picked up sent over to the db however this is important. I just want the warranty, delivery and price fields to be sent over.
As I've mentioned earlier, I have another form which uses the exact same method and works completely fine. This what bugs me as I can't understand why 1 form would work while the other doesn't.
Thanks for any help.