简体   繁体   English

使用会话 PHP MySQL 更新配置文件

[英]Update profile using session PHP MySQL

I'm doing project in eCommerce website using PHP and MySQL.我正在使用 PHP 和 MySQL 在电子商务网站上做项目。 I'm having a problem updating user profile page - when I click update button then I check the database, nothing is changed.我在更新用户配置文件页面时遇到问题 - 当我单击更新按钮然后检查数据库时,没有任何更改。 These is my update.php .这是我的update.php

<?php
    session_start();     
    if(!isset($_SESSION["n"]))
       {
         header("location:error.php");
       }
    if(isset($_POST["submit"]))
     {

      $nm=$_POST["name"];
      $lnm=$_POST["lname"];
      $ad=$_POST["add"];

      $u=$_SESSION["un"];

      $id=$_GET["id"];


         require_once("vars.php");
$conn=mysqli_connect(host,uname,pass,db) or die(mysqli_connect_error());

         $query="update signup set name='$nm', lname='$lnm', address='$ad' where User_ID='$id' ";

         $execute=mysqli_query($conn,$query);$r=mysql_affected_rows();
         mysqli_close($conn);

         if(!$execute)
          {
              $msg="Information Updated Successfully";

          }



           header("location:mydetails.php");
     }  


    ?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<table width="950" align="center">
  <tr>
    <td>
      <table cellspacing="0" cellpadding="0" width="100%">
        <tr align="right">
          <td>Welcome 
          <?php
              if(isset($_SESSION["n"]))
                    {
                       print $_SESSION["n"];

                       print "&nbsp;<a href='myprofile.php'>My Profile</a>";
                       print "&nbsp;<a href='signout.php'>Log Out</a>";
                    }
              else
                    {
                       print "Guest &nbsp;";
                       print "<a href='signup.php'>Sign up</a>&nbsp;";
                       print "<a href='login.php'>Login</a>";                      

                     }
            ?></td>
        </tr>
        <tr>
               <td><img src="pics/new2.JPG" alt="banner" width="950" height="234" /></td>
        </tr>

        <tr align="center">
          <td height="58"><table width="100%">
            <tr align="center">

                  <td width="158" bgcolor="#f9b67b"><a href="index.php"><font color="#FFFFFF">Home</font></a></td>
                  <td width="158" bgcolor="#f9b67b" ><a href="aboutus.php"><font color="#FFFFFF">About us</font></a></td>
                  <td width="158" bgcolor="#f9b67b"><a href="showcat.php"><font color="#FFFFFF">Products</font></a></td>
                <td width="158" bgcolor="#f9b67b"><a href="searchproductbyname.php"><font color="#FFFFFF">Search</font></a></td>
                 <td width="158" bgcolor="#f9b67b"><a href="contactus.php"><font color="#FFFFFF">Contact us</font></a></td>

            </tr>
            <tr align="center">
                 <td colspan="6" align="left"><!-- InstanceBeginEditable name="EditRegion3" -->
                <table width="100%">
                  <tr>
                    <td><form id="form1" name="form1" method="post" action="">
                      <table width="100%">
                        <tr>
                          <td><h2><strong>Update My Information</strong></h2></td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>


                           <tr>
                          </label></td>
                        </tr>
                        <tr>
                          <td><strong>Name:</strong></td>
                          <td><label>
                            <input type="text" name="name" id="name" />
                          </label></td>
                        </tr>
                        <tr>
                          <td><strong>Last name:</strong></td>
                          <td><label>
                            <input type="text" name="lname" id="lname" />
                          </label></td>
                        </tr>
                        <tr>
                          <td><strong>Address:</strong></td>
                          <td><label>
                            <input type="text" name="ad" id="ad" />
                          </label></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td><label>
                            <input type="submit" name="submit" id="submit" value="Update" />
                            <input type="reset" name="reset" id="reset" value="Reset" /></td>
                          </label></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>

                        </tr>
                      </table>
                                        </form>
                    </td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                </table>
              <!-- InstanceEndEditable --></td>
              </tr>
          </table></td>
        </tr>
      </table>
            </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>

</table>
</body>

<div id="footer" >

<h4 style="text-align:center">&copy;2016 by www.thebeautyskin.com</h4>
</div>
<!-- InstanceEnd --></html>
</div>
update signup set name='$nm', lname='$lname', address='$ad'

Where are variables $nm and $ad defined?变量 $nm 和 $ad 在哪里定义? I see $name and $address....我看到 $name 和 $address ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM