Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取HTML表中用于模式jQuery的行ID;PHP_Javascript_Php_Jquery_Mysql_Ajax - Fatal编程技术网

Javascript 获取HTML表中用于模式jQuery的行ID;PHP

Javascript 获取HTML表中用于模式jQuery的行ID;PHP,javascript,php,jquery,mysql,ajax,Javascript,Php,Jquery,Mysql,Ajax,所以这次我有一个HTML表,当我点击位于标记中的锚时,它会打开一个模式,在那里我们可以更改用户密码 <header> <h3>Alterar Password</h3> </header> <div class="modal-body"> <form action="" method="POST" id="changepw" name="changepw"&g

所以这次我有一个HTML表,当我点击位于标记中的锚时,它会打开一个模式,在那里我们可以更改用户密码

      <header>
        <h3>Alterar Password</h3>
      </header>

      <div class="modal-body">

        <form action="" method="POST" id="changepw" name="changepw">            
            <label>Nova Password:</label><br/>
            <input class="textbox" type="password" name="newpassword" id="newpassword" /> <br/>

            <input class="btnSubmit" type="submit" name="changepwSub" id="changepwSub" form="changepw" value="Alterar Password" />          
        </form>         
      </div>

      <footer>
        <a href="#" class="js-modal-close"><input class="btnSubmit" type="button" value="Fechar" style="max-width:100px;" /></a>
      </footer>

      <?php

       //The PHP Code to Update it will be here.
        $query = "UPDATE auth SET password=xxx WHERE ID="

       ?>  
    </div>
但要更新用户表中的密码,我需要获取ID。我的问题是,如何在模式中获取行ID/用户ID

      <header>
        <h3>Alterar Password</h3>
      </header>

      <div class="modal-body">

        <form action="" method="POST" id="changepw" name="changepw">            
            <label>Nova Password:</label><br/>
            <input class="textbox" type="password" name="newpassword" id="newpassword" /> <br/>

            <input class="btnSubmit" type="submit" name="changepwSub" id="changepwSub" form="changepw" value="Alterar Password" />          
        </form>         
      </div>

      <footer>
        <a href="#" class="js-modal-close"><input class="btnSubmit" type="button" value="Fechar" style="max-width:100px;" /></a>
      </footer>

      <?php

       //The PHP Code to Update it will be here.
        $query = "UPDATE auth SET password=xxx WHERE ID="

       ?>  
    </div>
“我的表格”是通过以下内容创建的:

for ($i = 0; $i < $size; $i++) {
print ("
<tr>
<td>".$Users[$i][0]."</td>
<td>".$Users[$i][1]."</td>
<td>*****</td>
<td><a data-modal-id='delete' href='#' >Change PW</a></td>
</tr>
<tr>");
}
      <header>
        <h3>Alterar Password</h3>
      </header>

      <div class="modal-body">

        <form action="" method="POST" id="changepw" name="changepw">            
            <label>Nova Password:</label><br/>
            <input class="textbox" type="password" name="newpassword" id="newpassword" /> <br/>

            <input class="btnSubmit" type="submit" name="changepwSub" id="changepwSub" form="changepw" value="Alterar Password" />          
        </form>         
      </div>

      <footer>
        <a href="#" class="js-modal-close"><input class="btnSubmit" type="button" value="Fechar" style="max-width:100px;" /></a>
      </footer>

      <?php

       //The PHP Code to Update it will be here.
        $query = "UPDATE auth SET password=xxx WHERE ID="

       ?>  
    </div>
($i=0;$i<$size;$i++)的
{
打印(“
“$Users[$i][0]”
“$Users[$i][1]”
*****
");
}
因此,当我单击锚定时,模态打开,我可以设法使模态工作。我需要的是以某种方式获取ID来构建SQL查询以更新密码

      <header>
        <h3>Alterar Password</h3>
      </header>

      <div class="modal-body">

        <form action="" method="POST" id="changepw" name="changepw">            
            <label>Nova Password:</label><br/>
            <input class="textbox" type="password" name="newpassword" id="newpassword" /> <br/>

            <input class="btnSubmit" type="submit" name="changepwSub" id="changepwSub" form="changepw" value="Alterar Password" />          
        </form>         
      </div>

      <footer>
        <a href="#" class="js-modal-close"><input class="btnSubmit" type="button" value="Fechar" style="max-width:100px;" /></a>
      </footer>

      <?php

       //The PHP Code to Update it will be here.
        $query = "UPDATE auth SET password=xxx WHERE ID="

       ?>  
    </div>
模式:

      <header>
        <h3>Alterar Password</h3>
      </header>

      <div class="modal-body">

        <form action="" method="POST" id="changepw" name="changepw">            
            <label>Nova Password:</label><br/>
            <input class="textbox" type="password" name="newpassword" id="newpassword" /> <br/>

            <input class="btnSubmit" type="submit" name="changepwSub" id="changepwSub" form="changepw" value="Alterar Password" />          
        </form>         
      </div>

      <footer>
        <a href="#" class="js-modal-close"><input class="btnSubmit" type="button" value="Fechar" style="max-width:100px;" /></a>
      </footer>

      <?php

       //The PHP Code to Update it will be here.
        $query = "UPDATE auth SET password=xxx WHERE ID="

       ?>  
    </div>

交替密码
Nova密码:


您只需要3个步骤:

      <header>
        <h3>Alterar Password</h3>
      </header>

      <div class="modal-body">

        <form action="" method="POST" id="changepw" name="changepw">            
            <label>Nova Password:</label><br/>
            <input class="textbox" type="password" name="newpassword" id="newpassword" /> <br/>

            <input class="btnSubmit" type="submit" name="changepwSub" id="changepwSub" form="changepw" value="Alterar Password" />          
        </form>         
      </div>

      <footer>
        <a href="#" class="js-modal-close"><input class="btnSubmit" type="button" value="Fechar" style="max-width:100px;" /></a>
      </footer>

      <?php

       //The PHP Code to Update it will be here.
        $query = "UPDATE auth SET password=xxx WHERE ID="

       ?>  
    </div>
  • 按照注释中的建议,将用户ID嵌入到链接到单击的锚点/行/单元格/任何对象的数据集中。例如,
  • 修改生成模式的脚本以读取该数据并添加隐藏的表单字段。例如,
  • 在PHP脚本中,只需检索该额外字段以填充SQL查询

  • 我希望这是一种管理局,你有适当的凭据和安全。您可能需要在服务器端检查用户是否具有修改具有给定ID的用户记录的凭据,因为任何人都可以传递假ID并修改其他人的记录。

    这里的data modal userId=user ID
    以及如何在PHP变量中获取该ID?我假设它在$users中?问题不是将ID传递给data moda userId。问题是在模式打开后,当我单击Update Password时,如何在我编写查询的部分获得该ID?提前谢谢。
          <header>
            <h3>Alterar Password</h3>
          </header>
    
          <div class="modal-body">
    
            <form action="" method="POST" id="changepw" name="changepw">            
                <label>Nova Password:</label><br/>
                <input class="textbox" type="password" name="newpassword" id="newpassword" /> <br/>
    
                <input class="btnSubmit" type="submit" name="changepwSub" id="changepwSub" form="changepw" value="Alterar Password" />          
            </form>         
          </div>
    
          <footer>
            <a href="#" class="js-modal-close"><input class="btnSubmit" type="button" value="Fechar" style="max-width:100px;" /></a>
          </footer>
    
          <?php
    
           //The PHP Code to Update it will be here.
            $query = "UPDATE auth SET password=xxx WHERE ID="
    
           ?>  
        </div>