Php 在一列多行中插入多个复选框
我有一个带有多个复选框的页面。我的代码将每个复选框插入到一个单独的列中,尽管这会在我再次查看信息时引起问题 我以前可以在一列中插入答案,但答案都放在一个字段中,而不是单独的行中。我还需要登录用户的用户id,以便为选中的每个框插入到每行中 任何人都可以复制和修改我的代码,以便能够插入到一列(响应)和单独的行中,以及用户id 这是我的密码,谢谢Php 在一列多行中插入多个复选框,php,mysql,checkbox,Php,Mysql,Checkbox,我有一个带有多个复选框的页面。我的代码将每个复选框插入到一个单独的列中,尽管这会在我再次查看信息时引起问题 我以前可以在一列中插入答案,但答案都放在一个字段中,而不是单独的行中。我还需要登录用户的用户id,以便为选中的每个框插入到每行中 任何人都可以复制和修改我的代码,以便能够插入到一列(响应)和单独的行中,以及用户id 这是我的密码,谢谢 <?php session_start(); include_once 'dbconnect.php'; if(!isset($_SESSION
<?php
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
if(isset($_POST['submit']))
{
header("Location: eNISATVids.php");
@$userID=$_SESSION['user'];
@$checkbox1=$_POST['Log'];
@$checkbox2=$_POST['Worktray'];
@$checkbox3=$_POST['Visual'];
@$checkbox4=$_POST['ChangePd'];
@$checkbox5=$_POST['Logout'];
@$checkbox6=$_POST['ClientSearch'];
@$checkbox7=$_POST['StartAssessment'];
@$checkbox8=$_POST['Finalise'];
@$checkbox9=$_POST['Print'];
@$checkbox10=$_POST['Hcn'];
@$checkbox11=$_POST['Lcid'];
@$checkbox12=$_POST['Soscare'];
@$checkbox13=$_POST['Reassign'];
@$checkbox14=$_POST['Close'];
$query="INSERT INTO enisatanswer (user_id,Log,Worktray,Visual,ChangePd,Logout,ClientSearch,StartAssessment,Finalise,Print,Hcn,Lcid,Soscare,Reassign,Close) VALUES
('$userID', '$checkbox1', '$checkbox2','$checkbox3', '$checkbox4', '$checkbox5', '$checkbox6','$checkbox7', '$checkbox8','$checkbox9', '$checkbox10','$checkbox11', '$checkbox12', '$checkbox13', '$checkbox14')";
mysql_query($query) or die (mysql_error() );
if($query==true)
{
echo'<script>alert("Your choices have inserted Successfully \n \n Please click on Display eNISAT Tutorials at the buttom of the page to view your videos ")</script>';
}
else
{
echo'<script>alert("Failed To Insert")</script>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['username']; ?></title>
/<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<div id="left">
<label>NHSCT eNISAT Tutorials</label>
</div>
<div id="right">
<div id="content">
Welcome <?php echo $userRow['forename']; ?> <a href="logout.php?logout">Sign Out</a>
</div>
</div>
</div>
<br>
<p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg">
<br>
<br>
<center>
<h2>Please select the tasks you require assistance with, before clicking DISPLAY ENISAT TUTORIALS:<h2>
<br>
<table align="center" height="0" width="70%" border="1" bgcolor = "white">
<form action="" method="post"
<tr>
<td colspan="2">Tick each relevant box:</td>
</tr>
<tr>
<td>How to login</td>
<td><input type="checkbox" name="Log" value="1"></td>
<tr>
<td>How to manage your worktray</td>
<td><input type="checkbox" name="Worktray" value="1"></td>
<tr>
<td>How to change your visual settings (Colours and text size)</td>
<td><input type="checkbox" name="Visual" value="1"></td>
</tr>
<tr>
<td>How to change your own password on the system</td>
<td><input type="checkbox" name="ChangePd" value="1"></td>
</tr>
<tr>
<td>How to logout of the system</td>
<td><input type="checkbox" name="Logout" value="1"></td>
</tr>
<tr>
<td>How to search for a client on the system</td>
<td><input type="checkbox" name="ClientSearch" value="1"></td>
</tr>
<tr>
<td>How to start an assessment</td>
<td><input type="checkbox" name="StartAssessment" value="1"></td>
</tr>
<tr>
<td>How to finalise an assessment</td>
<td><input type="checkbox" name="Finalise" value="1"></td>
<tr>
<td>How to print an assessment</td>
<td><input type="checkbox" name="Print" value="1"></td>
</tr>
<tr>
<td>How to create a client and referral manually through Find on H+C</td>
<td><input type="checkbox" name="Hcn" value="1"></td>
</tr>
<tr>
<td>How to submit a referral from LCID (LCID Users only)</td>
<td><input type="checkbox" name="Lcid" value="1"></td>
</tr>
<tr>
<td>How to submit a referral from Soscare (Soscare Users only)</td>
<td><input type="checkbox" name="Soscare" value="1"></td>
</tr>
<tr>
<td>How to reassign a referral on eNISAT</td>
<td><input type="checkbox" name="Reassign" value="1"></td>
</tr>
<tr>
<td>How to close a referral on eNISAT</td>
<td><input type="checkbox" name="Close" value="1"></td>
</tr>
<tr>
<td <td><button name="submit" type="submit" onclick="window.location.href='eNISATVids.php'">Display eNISAT Tutorials</button></td>
</tr>
</table>
</div>
</form>
</body>
</html>
欢迎-
/
NHSCT eNISAT教程
欢迎
请选择需要帮助的任务,然后单击“显示ENISAT教程”:
旁注:您的代码非常容易受到攻击-另外:mysql_u函数已被弃用,请改用mysqli_uu或pdo。。。。。当我希望再次提取信息时会导致问题。什么问题?我希望能够将每个复选框值关联到另一个表中的一行,以显示视频内容,但每次只能显示一个内容。这只是一个原型,它不会在公共领域使用,我知道这些功能被贬低了,但我现在只需要让它以现有的格式工作,因为我剩下的时间很少