【发布时间】:2015-01-14 20:20:07
【问题描述】:
在注册部分会有一些图像,它会在每次刷新时自动洗牌。用户应该选择一个或多个图像(勾选相应的复选框),它将存储在数据库中而不是密码中。它将正常工作,问题出在登录页面。我希望复选框的值按检查顺序排列。这意味着如果我选中第二个复选框,然后选中第一个框,那么值将得到相同的顺序。
这里是代码
<?php
include("config.php");
if(isset($_POST['s'])){
$username=$_POST['username'];
if(isset($_POST['chk1']))
{
$t1=implode(',', $_POST['chk1']);
}
echo $t1;
$query=mysql_query("select *from register where username='$username' and password='$t1'");
$res=mysql_num_rows($query);
if($res>0)
{
session_start();
$_SESSION['usr']=$username;
header("location:userhome.php");
}
else
{
echo mysql_error();
}
}
?>
<body>
<form action="" method="post">
<table width="200" border="0">
<th colspan="2" scope="row"><a href="register.php">
<font color="#FF0000">New Registration</font> </a></th>
</tr>
<tr>
<th scope="row">Username</th>
<td><label for="username"></label>
<input type="text" name="username" id="username" /></td>
</tr>
<tr>
<th colspan="2" scope="row"><u>Choose Password</u></th>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
</table>
<div align="center">
<?php
$images = array(
'<input name="chk1[]" type="checkbox" value="1" />
<img src="images/images (4).jpg" alt="" width="234" height="212" />',
'<input name="chk1[]" type="checkbox" value="2" />
<img src="images/images (6).jpg" alt="" width="234" height="212" />',
'<input name="chk1[]" type="checkbox" value="3" />
<img src="images/images (5).jpg" alt="" width="234" height="212" />',
'<input name="chk1[]" type="checkbox" value="4" />
<img src="images/drt.jpg" alt="" width="234" height="212" />',
'<input name="chk1[]" type="checkbox" value="5" />
<img src="images/rf.jpg" alt="" width="234" height="212" />',
'<input name="chk1[]" type="checkbox" value="6" />
<img src="images/yu.jpg" alt="" width="234" height="212" />',
'<input name="chk1[]" type="checkbox" value="7" />
<img src="images/ed.jpg" alt="" width="234" height="212" />'
);
shuffle($images); // Randomize images array;
echo $images[0];
echo $images[1];
echo $images[2];
echo $images[3];
echo $images[4];
echo $images[5];
echo $images[6];
?>
【问题讨论】:
-
有人有解决办法吗,请帮帮我
-
请给我一个解决方案..