gpt4 book ai didi

php - 将下拉列表数据添加到 MySQL 数据库

转载 作者:行者123 更新时间:2023-11-30 00:36:37 25 4
gpt4 key购买 nike

我无法将注册页面上的下拉菜单中的数据插入到数据库中。

这是注册页面:

      <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";
?>

我不知道我做错了什么,有人可以帮忙吗?

最佳答案

分配给选项作为

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

关于php - 将下拉列表数据添加到 MySQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22116293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com