2014-03-01 84 views
0

我无法对我的注册页面,我的数据库中插入从我的下拉菜单中的数据。添加下拉列表数据到MySQL数据库

这里是注册页面:

 <html> 
     <title>favNet!</title> 
<head> 
<link href="CSS/main.css" rel="stylesheet" type="text/css"> 
</head> 
<body> 
<div class="headerMenu"> 
    <div id="wrapper"> 
     <div class="logo"> 
     <a href="index.html"><img src="pics/logo.png"></a> 
      <div id="menu"> 
       <a href="index.html">Home</a> 
       <a href="about.html">About</a> 
       <a href="#">Contact</a> 
       <a href="#">FAQ & Rules</a> 
      </div> 
     </div> 
    </div> 
</div> 
<table> 
<tr> 
    <td width="15%" valign="top"> 
    <br /> 
     <h1 align="center">Already a Member? Login Below</h1> 
     <br/> 
      <form action="#" method="POST" align="center"> 
       <input class ="textbox" type="text" size="25" name="username" placeholder="Username"/><br /><br /> 
       <input class ="textbox" type="password" size="25" name="password" placeholder="Password"/><br /><br /> 
       <input class= "submit" type="submit" name="submit" value="Sign In"> 
       <br /> 
       <br /> 
       <br /> 
       <br /> 
       <img src="pics/sidemenu_img.png" width="350" height="300"> 
      </form> 
    </td> 
    <td width="55%" valign="top"> 
    </td> 
    <td width="30%" valign="top"> 
     <br /> 
     <h1 align="center">Not Enjoying the Awesomeness???</h1> 
     <h1 align="center">Than Sign Up Here!!!</h1> 
    </br /> 
     <form action="signed-up.php" method="POST" align="center"> 
     <input class ="textbox" type="text" size="25" name="fname" placeholder="First Name"/><br /><br /> 
     <input class ="textbox" type="text" size="25" name="lname" placeholder="Last Name"/><br /><br /> 
     <input class ="textbox" type="text" size="25" name="username" placeholder="Username"/><br /><br /> 
     <input class ="textbox" type="text" size="25" name="nname" placeholder="Nickname"/><br /><br /> 
     <input class ="textbox" type="text" size="25" name="email" placeholder="Email"/><br /><br /> 
     <input class ="textbox" type="text" size="25" name="age" placeholder="Age (Example: 21)"/><br /><br /> 
     <input class ="textbox" type="password" size="25" name="password" placeholder="Password"/><br /><br /> 
     <input class ="textbox" type="password" size="25" name="password2" placeholder="Repeat Password"/><br /><br /> 
     <select align="right" class="select" name="tv"> 
      <option>Favorite TV Show</option> 
      <option>Game of Thrones</option> 
      <option>Breaking Bad</option> 
      <option>The Walking Dead</option> 
      <option>The Simpsons</option> 
      <option>South Park</option> 
      <option>Family Guy</option> 
      <option>Arrested Development</option> 
      <option>American Horror Story</option> 
      <option>True Detective</option> 
      <option>Once Upon a Time</option> 
      <option>Pretty Little Liars</option> 
     </select> 
     <br /> 
     <br /> 
     <select align="right" class="select" name="movie"> 
      <option>Favorite Movie Series</option> 
      <option>Star Wars</option> 
      <option>Fast & Furious</option> 
      <option>Lord of the Rings/The Hobbit</option> 
      <option>Harry Potter</option> 
      <option>Star Trek</option> 
      <option>The Avengers</option> 
      <option>Batman</option> 
      <option>James Bond</option> 
      <option>Pirates of the Caribbean</option> 
      <option>X-Men</option> 
      <option>Transformers</option> 
      <option>The Hunger Games</option> 
      <option>The Hangover</option> 
      <option>Alien</option> 
      <option>Predator</option> 
      <option>Jurassic Park</option> 
      <option>Ghostbusters</option> 
      <option>Back to the Future</option> 
      <option>Die Hard</option> 
      <option>Rush Hour</option> 
      <option>Planet of the Apes</option> 
      <option>Austin Powers</option> 
      <option>American Pie</option> 
     </select> 
     <br /> 
     <br /> 
     <select align="right" class="select" name="book" id="book"> 
      <option>Favorite Book Series</option> 
      <option value="Harry Potter">Harry Potter</option> 
      <option value="Game of Thrones">Game of Thrones</option> 
      <option value="Lord of the Rings/The Hobbit">Lord of the Rings/The Hobbit</option> 
      <option value="Percy Jackson">Percy Jackson</option> 
      <option value="The Hunger Games">The Hunger Games</option> 
      <option value="Diary of a Wimpy Kid">Diary of a Wimpy Kid</option> 
      <option value="Goosebumps">Goosebumps</option> 
      <option value="The Mortal Instruments">The Mortal Instruments</option> 
      <option value="The Chronicles of Narnia">The Chronicles of Narnia</option> 
     </select> 
     <br /> 
     <br /> 
     <input class= "submit" type="submit" name="submit" value="Sign Up"> 
     </form> 
    </td> 
</tr> 
</table> 
</body> 
</html> 

这里是我签约了页面,表单中的信息被添加到数据库中。

<?php 
$con = mysql_connect("localhost","root",""); 
if (!$con) 
    { 
    die('Could not connect: ' . mysql_error()); 
    } 


mysql_select_db("favnet", $con); 

extract($_POST); 

$sql="INSERT INTO membership (FirstName,LastName,Age,Email,Username,Nickname,TV,Movie,Book) VALUES ('$fname','$lname','$age','$email','$username','$nname','$tv','$movie','$book')"; 

// Execute query 
if(mysql_query($sql,$con) === false) 
{ 
    echo mysql_error() . "<br />$sql"; 
} 

mysql_close($con); 
print "Record Added"; 
?> 

我不知道我在做什么错,任何人都可以帮忙吗?

回答

0

分配valueoption s可通过提交表单选择(下拉列表)的数据当作为

<select align="right" class="select" name="tv"> 
     <option value="favourite show">Favorite TV Show</option> 
     ... 
    </select> 
0

,所有代码都需要将通过POST发送的价值属性。将价值属性添加到电影和电视的选项,就像使用书籍一样。