javascript - 在我的弹出窗口上更新密码的问题
问题描述
当我尝试在 mysql db 上更新密码时,我将 html 用于带有 JS 和 CSS 的面板。我使用带有 CSS 的锚点在 html 中弹出了一个弹出窗口,但是当我单击更新密码时没有任何反应。
这是我弹出的一个面板,用户可以使用电子邮件和密码登录。
section id="section4" >
<h2>MIS DATOS</h2>
<p class="intro">Nombre: <?php echo ' '; echo $nombre; echo ' '; echo $apellido ?><br>
PROVINCIA: <?php echo ' '; echo $prov; ?> <br>
DIRECCIÓN: <?php echo ' '; echo $dir; ?><br>
CP: <?php echo ' '; echo $cp; ?><br>
CUIT: <?php echo ' '; echo $cuit; ?><br>
TELÉFONO: <?php echo ' '; echo $cel; ?><br>
E-MAIL: <?php echo ' '; echo $email; ?></p>
<link href="popup.css" rel="stylesheet" type="text/css"/>
<p class="envio">
<a href="#popup" style="text-decoration:none" color="#FFF" class="button"><font color="white" SIZE="2">Cambiar contraseña</font></a>
</p>
<div id="popup" class="overlay">
<div id="popupBody">
<h3 align="center">Cambiar contraseña</h3>
<a id="cerrar" href="#">×</a>
<form action="../password.php" method="post">
<div class="contenedor-inputs" align="center">
<br>
<input type="password" placeholder="Password actual" class="introd" name="pdw_orig" > <br>
<input type="password" placeholder="Password nuevo" class="introd" name="pdw_new1"> <br>
<input type="password" placeholder="Password nuevo" class="introd" name="pdw_new2"> <br>
<br>
<input type="submit" class="button" value="cambiar" name="pwd" action ="../password.php">
</div>
css 没问题,但我也放了它(仅用于“弹出窗口”)。
@charset "utf-8";
body {
font-family: 'Titillium Web', sans-serif;
font-size: 18px;
line-height: 2.35;
color: rgba(255, 255, 255, 0.85);
margin: 0;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.8);
transition: opacity 700ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
#popupBody{
width: 15%;
padding: 0%;
border-radius: 5px;
box-shadow: 0 0 5px #CCC;
background: #1e3466;
position: relative;
transition: all 1s ease-in-out;
margin: 20% auto;
}
#cerrar{
position: absolute;
top: 3px;
right: 10px;
transition: all 200ms;
font-size: 18px;
font-weight: bold;
text-decoration: none;
color: #FFF;
}
.button {
width: 100px;
text-transform: uppercase;
background: #DE680C;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 10px 10px 10px 10px;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
.introd {
margin-top:20px;
text-align: center;
height: 25px;
border: 0 none;
border-radius: 10px 10px 10px 10px;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
font-size: 15px;
}
section h3 {
margin: 0;
color: #DE680C;
text-transform: uppercase;
text-align: center;
padding-top: 50px;
letter-spacing: 1px;
-webkit-animation: float-in-right 0.45s ease;
animation: float-in-right 0.45s ease;
}
a.button {
text-align: center;
width: 23%;
text-transform: uppercase;
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
text-decoration: none;
color: initial;
border: 0 none;
}
现在问题出在哪里(php代码)
<?php
session_start();
if(isset($_SESION['email'])){
header('location: index.php');
}
if (isset($_POST['pwd']))
{
include_once("con_db.php");
$usuario = $_SESSION['email'];
$pdw_orig = $mysqli->real_escape_string($_POST['pwd_orig']);
$pdw_new1 = $mysqli->real_escape_string($_POST['pwd_new1']);
$pdw_new2 = $mysqli->real_escape_string($_POST['pwd_new2']);
$pwd_orig = hash('sha512', $pwd_orig);
$pwd_new1 = hash('sha512', $pwd_new1);
$pwd_new2 = hash('sha512', $pwd_new2);
$sqla = $mysqli->query("SELECT password FROM datos Where email = $usuario");
$rowa = $sqla->fetch_array();
if($rowa['password'] == $pass_orig ){
if ($pwd_new1 == $pwd_new2){
$passUpdate = $mysqli->query("UPDATE datos SET password = '$pwd_new1' WHERE email = $usuario");
if($update) { echo "<script> alert('Cambio de contraseña correcto! deberá iniciar sesión nuevamente');window.location='panel.php'</script>";
sleep(15);
header ('location: ../index.php');
}else {
echo "<script> alert('Las contraseñas nuevas no coinciden!');window.location='panel.php'</script>";
}
}
}else{"<script> alert('Tu contraseña actual no coincide');window.location='panel.php'</script>";
}
?>
存档 con_db.php 工作正常,因为当我需要在我的数据库上做某事时,我总是使用它。
我不知道问题是什么。
解决方案
SELECT
您的查询有问题;$sqla = $mysqli->query("SELECT password FROM datos Where email = $usuario");
您已经直接在字符串中声明了变量,因此它实际上是在寻找与字符串“$usuario”匹配的电子邮件,而不是 PHP 变量传递的内容。而是尝试;
$sqla = $mysqli->query("SELECT password FROM datos WHERE email = '" . $usuario . "'");
编辑--- WHERE 也应该全部大写,我错过了您需要将变量括在单引号中。
您的更新查询再次相同... $passUpdate = $mysqli->query("UPDATE datos SET password = '$pwd_new1' WHERE email = $usuario");
应该是这个->$passUpdate = $mysqli->query("UPDATE datos SET password = '" . $pwd_new1 . "' WHERE email = '" . $usuario . "'");
推荐阅读
- python - 文件执行错误 - 没有名为“pywinauto”的模块
- python - Python:对于每一行,获取下一个较早的日期,其中 value > 0
- javascript - 访问这种类型的 Json 对象
- java - 我在我的 JavaFX 项目中找不到这个问题的答案:java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
- keras - 有什么方法可以将 weight.pt 模型转换为 weight.h5 或 weight.weights 转换为 weight.h5 格式
- java - Integer.toString() 行为怪异
- sql - 基于合并列的计数
- bash - 递归打印和删除匹配两种模式之一的文件
- android - 如何使用 ViewPager 使 ScrollView 中的 Stickable TabView 反应原生?
- php - 从 SimpleXMLElement 获取变量