gpt4 book ai didi

php - 如何获取用户在表单中选择的多张图片并显示在下一页?

转载 作者:行者123 更新时间:2023-11-29 18:46:18 25 4
gpt4 key购买 nike

`

  <?php
ob_start();
session_start();
include_once 'dbconnect.php';
$error = false;
if ( isset($_POST['cust-submit2']) ) {
$pass1 = trim($_POST['cust-acc-pwd']);
$pass1 = strip_tags($_POST['cust-acc-pwd']);
$pass1 = htmlspecialchars($_POST['cust-acc-pwd']);
$pass2 = trim($_POST['cust-confirm-pwd']);
$pass2 = strip_tags($_POST['cust-confirm-pwd']);
$pass2 = htmlspecialchars($_POST['cust-confirm-pwd']);
$_POST = $_SESSION;
$acc_no = $_POST['cust-acc-no'];

echo "<h1>$acc_no</h1>";

if(empty($pass1) || empty($pass2)){
$error = true;
$passError = "Please enter your password.";
echo $passError;
}else if( strlen($pass1) < 6) {
$error = true;
$passError = "Password must have atleast 6 characters.";
echo $passError;
}

if (!$error){
if($pass1 == $pass2){

// password encrypt using SHA256();
$newpass = hash('sha256', $pass1);


$query = "UPDATE users SET userPass = '$newpass' WHERE
Account_no='$acc_no'";
$res = mysql_query($query);


if($res){
$errTyp = "<h1>success</h1>";
$errMSG = "<h2>Successfully Password Changed</h2>";
echo $errTyp;
echo $errMSG;
unset($pass1);
unset($pass2);
}
else{
$errMSG = "<h1>Failure!Try again later..</h1>";
echo $errMSG;
}
}
else{
echo "Passwords do not match";
}
}
if(!empty($_POST['check_list'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['check_list']);
echo "You have selected following ".$checked_count." option(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['check_list'] as $selected) {
echo "<p>".$selected ."</p>";
}
}
else{
echo "<b>Please Select Atleast One Option.</b>";
}
}

$_POST = $_SESSION;

?>
<html>
<head>
<title>Online Bank</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"








href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
<link rel="stylesheet" href="banking.css">
<script src="banking.js"></script>
</head>
<body>
<div class="container">
<h1 class="float-left">Online Bank</h1>
<h1 class="float-right">Online Bank</h1>
<br>
<br>
<br>
<hr>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Home</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Register</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</nav>
<br>
<div class="col-md-12">
<form method="post" action="">
Welcome <?php if(!empty($_POST['cust-acc-no'])) echo $_POST['cust-
acc-no'] ; ?>
<div class="col-md-4">
<h3 class="text-center">Customer Panel</h3>
<br>
<!-- <form method="post" action="">
Welcome <?php if(!empty($_POST['cust-acc-no']))
echo $_POST['cust-acc-no'] ; ?> -->
<div class="form-group">
<label for="cust-acc-pwd">Enter your New
Password</label>
<input type="text" class="form-control" name="cust-acc-
pwd" id="cust-acc-pwd">
</div>
<div class="form-group">
<label for="cust-confirm-pwd">Confirm your New Password:
</label>
<input type="password" class="form-control" name="cust-
confirm-pwd" id="cust-confirm-pwd">
</div>
<label for="usr">Select your Security Image: </label>
<br><br>
<button type="submit" class="btn btn-default btn-primary"
name="cust-submit2"><a class="a-btn">Submit</a></button>
<!-- </form> -->
</div>
<div class="col-md-8 d3 mt0">
<h3 class="text-center pb20 mt0">Select Upto 4 Random
Images</h3>
<div class="d3-2">
<div class="d4">
<div class="d5">
<div class="col-md-12">
<div class="col-md-4"><img
src="reg_images/01.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="01.jpg" id="img1"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/02.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="02.jpg" id="img2"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/03.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="03.jpg" id="img3"></label>
</div>
</div>
</div>

<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/04.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="04.jpg" id="img4"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/05.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="05.jpg" id="img5"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/06.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="06.jpg" id="img6"></label>
</div>
</div>
</div>

<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/07.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="07.jpg" id="img7"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/08.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="08.jpg" id="img8"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/09.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="09.jpg" id="img9"></label>
</div>
</div>
</div>

<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/10.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="10.jpg" id="img10"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/11.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="11.jpg" id="img11"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/12.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="12.jpg" id="img12"></label>
</div>
</div>
</div>

<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/13.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="13.jpg" id="img13"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/14.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="14.jpg" id="img14"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/15.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="15.jpg" id="img15"></label>
</div>
</div>
</div>

</div>
</div>
</div>
</div>
</form>
</div>


</div>

</body>
<html>

`我创建了一个注册页面(signup2.php),其中要求用户为他选择 4 个安全图像以及其他详细信息。然后,当用户登录时,在他选择的 4 张图像中,我想随机显示 4 张图像中的一张图像以及其他一些随机图像,并且用户只有选择正确的图像才应该能够登录。用户还必须选择 4 张图像,否则他将无法注册。我怎样才能做到这一点?我正在使用 PHP 和 MySql 开发网站。任何快速帮助将不胜感激!

最佳答案

要解决此问题,您可以使用隐藏的文本框。在 4 个图像上添加一个 onclick 事件,该事件将更新隐藏文本框的值。因此,当提交表单时,文本框将随表单一起发送,只需检查该文本框并查看它是否具有您期望的值。

下面的代码是一个示例,您应该添加更多内容以使图像以某种方式标记,以使用户明白它已被标记,但我将这部分留给您。

<div>
<input id="securityImage" type="hidden" value="" />
<img src="1.png" onlick="$("#securityImage").val("1");" />
<img src="2.png" onlick="$("#securityImage").val("2");" />
<img src="3.png" onlick="$("#securityImage").val("3");" />
<img src="4.png" onlick="$("#securityImage").val("4");" />
</div>

关于php - 如何获取用户在表单中选择的多张图片并显示在下一页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44612257/

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