2016-03-25 14 views
0

Oturum açmış kullanıcı bilgilerini içeren bir kullanıcı profil sayfam var. Gördüğünüz gibi, gönder butonu ile değiştirilmiş bilgiler bir edit_profile.php dosyasına gönderilir ve kontrol ettim eko ​​ile görünür. Her şey nedenini bilmediğim parola dışında gelir.Kullanıcı profil bilgilerini güncellemek için MySQL'e dön

Sorunun, SQL'i güncelleştirmek için yeni güncelleştirilmiş ayrıntıları nasıl edinebilirim.

Benim profil sayfam. Gönder düğmesine Eğer şu anda bu hangi edit_profile.php için gereken basıldığında

 <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
<!-- Include all compiled plugins (below), or include individual files as needed --> 
<script src="js/bootstrap.min.js"></script> 






</body> 
</html> 

<!-- loads the php file into here --> 
<?php 

/* This script pulls the existing name input and displays it when the user logs in. */ 

session_start(); 

include("connection.php"); 

$query="SELECT * FROM users WHERE id='".$_SESSION['id']."' LIMIT 1"; 

$result = mysqli_query($link,$query); 

$row = mysqli_fetch_array($result); 




?> 


<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 
<title>MyBday</title> 

<!-- Bootstrap --> 
<link href="css/bootstrap.min.css" rel="stylesheet"> 

<link href='https://fonts.googleapis.com/css?family=Lato:400,300,100,300italic' rel='stylesheet' type='text/css'> 

    <link rel="stylesheet" type="text/css" href="resources/css/profilestyles.css"> 


<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
<!--[if lt IE 9]> 
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
<![endif]--> 


</head> 



<body data-spy="scroll" data-target=".navbar-collapse"> 

<div class="navbar navbar-default navbar-fixed-top"> 

<div class="container"> 

    <div class="navbar-header"> 

     <button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> 

      <span class="icon-bar"></span> 

      <span class="icon-bar"></span> 

      <span class="icon-bar"></span> 

     </button> 

     <a class="navbar-brand">MyBday</a> 

    </div> 

     <div class="collapse navbar-collapse"> 



      <form class="navbar-form navbar-right" method="post"> 

      <ul class="nav nav-pills"> 
       <li role="presentation"><a href="mainpage.php">My connections</a></li> 
       <li role="presentation"><a href="#">World connections</a></li> 
       <li role="presentation" class="active"><a href="profile.php">Profile</a></li>  
       <li role="presentation"><a href="#">Messages</a></li> 
       <li role="presentation"><a href="index.php?logout=1">Logout</a></li> 
      </ul> 


      </form> 

     </div> 


    </div> 
</div> 




    <div class="container"> 
    <h1>Edit Profile</h1> 
    <hr> 
    <div class="row"> 
     <!-- left column --> 
     <div class="col-md-3"> 
     <div class="text-center"> 
     <img src="//placehold.it/100" class="avatar img-circle" alt="avatar"> 
     <h6>Upload a different photo...</h6> 

     <input class="form-control" type="file"> 
    </div> 
    </div> 

    <!-- edit form column --> 
    <div class="col-md-9 personal-info"> 
    <div class="alert alert-info alert-dismissable"> 
     <a class="panel-close close" data-dismiss="alert">×</a> 
     <i class="fa fa-coffee"></i> 
     This is an <strong>.alert</strong>. Use this to show important messages to the user. 
    </div> 
    <h3>Personal info</h3> 

    <form class="form-horizontal" role="form" action="edit_profile.php" method="post"> 

     <div class="form-group"> 
     <label class="col-lg-3 control-label name">name:</label> 
     <div class="col-lg-8"> 
     <input class="form-control" value="<?php echo $row['name'];?>" type="text" name="name"> 
     </div> 
     </div> 
     <div class="form-group"> 
     <label class="col-lg-3 control-label">Email:</label> 
     <div class="col-lg-8"> 
      <input class="form-control" value="<?php echo $row['email'];?>" type="text" name="email"> 
     </div> 
     </div> 
     <div class="form-group"> 
     <label class="col-lg-3 control-label">DOB:</label> 
     <div class="col-lg-8"> 
      <input class="form-control" value="<?php echo $row['DOB'];?>" type="date" name="DOB"> 
     </div> 
     </div> 
     <div class="form-group"> 
     <label class="col-lg-3 control-label">Country</label> 
     <div class="col-lg-8"> 
      <input class="form-control" value="<?php echo $row['country'];?>" type="text" name="country"> 
     </div> 
     </div> 

     <div class="form-group"> 
     <label class="col-md-3 control-label">Password:</label> 
     <div class="col-md-8"> 
      <input class="form-control" value="<?php echo $row['pasword'];?>" placeholder="At least 8 characters and 1 cap letter" type="password" name="password"> 
     </div> 
     </div> 
     <div class="form-group"> 
     <label class="col-md-3 control-label">Confirm password:</label> 
     <div class="col-md-8"> 
      <input class="form-control" value="<?php echo $row['pasword'];?>" placeholder="At least 8 characters and 1 cap letter" type="password" name="password"> 
     </div> 
     </div> 
     <div class="form-group"> 
     <label class="col-md-3 control-label"></label> 
     <div class="col-md-8"> 
      <input class="btn btn-primary" value="Save Changes" type="submit"> 
      <span></span> 
      <input class="btn btn-default" value="Cancel" type="reset"> 
     </div> 
     </div> 

    </form> 
    </div> 

.

<?php 

session_start(); 

include("connection.php"); 

$query="SELECT * FROM users WHERE id='".$_SESSION['id']."' LIMIT 1"; 

$result = mysqli_query($link,$query); 

$row = mysqli_fetch_array($result); 







$name= $_POST['name']; echo $name; 
$email= $_POST['email']; echo $email; 
$DOB= $_POST['DOB']; echo $DOB; 
$country= $_POST['country']; echo $country; 
$password= $_POST['password']; echo $password; 



?> 

Veritabanını güncellemek için burada hangi komut dosyası eksik? Ve ben Herhangi bir yardım çok takdir boş edit_profile.php sayfa

kullanıcıyı doğrudan olmadığından emin olun nasıl. parolası hakkında

cevap

1

, şuna bak:

$row['pasword'] 

Ben o zaman kullanmak gibi, orada bir sorun olduğunu düşünüyorum:

<div class="form-group"> 
     <label class="col-md-3 control-label">Password:</label> 
     <div class="col-md-8"> 
      <input class="form-control" value="<?php echo $row['pasword'];?>" placeholder="At least 8 characters and 1 cap letter" type="password" name="password"> 
     </div> 
     </div> 
     <div class="form-group"> 
     <label class="col-md-3 control-label">Confirm password:</label> 
     <div class="col-md-8"> 
      <input class="form-control" value="<?php echo $row['pasword'];?>" placeholder="At least 8 characters and 1 cap letter" type="password" name="password"> 
     </div> 
     </div> 

Eğer yazım hatası görüyor musunuz

$password= $_POST['password']; echo $password; 

:

Sonra gibi, güncelleme için sorgu oluşturmak gerekir

$query = "UPDATE users column_name='".$name."', ' ... WHERE id='".$_SESSION['id']."'"; 

ve çalıştırmak:

http://www.w3schools.com/php/php_mysql_update.asp

Selamlar

+0

Büyük başarmış, teşekkür ederim: güncelleme başarısı için

$result = mysqli_query($link,$query); 

kullanın onay, bu oldukça basit yap. Sayende. – will

İlgili konular