Этот код не работает для редактирования входа в профиль пользователя.Зачем? - PullRequest
0 голосов
/ 28 марта 2019

Этот код определен как редактирование профиля пользователя вошедшего в систему. Показать всю информацию о зарегистрированном пользователе, а также весь код, запущенный без ошибок. но не обновляет информацию о пользователях.

показать сообщение об успешном обновлении. но на самом деле обновления в базе данных не происходит.

и в URL не отображаются идентификаторы ссылок, которые сейчас редактируются.

edit.php

<?php
// We need to use sessions, so you should always start sessions using the below code.
    session_start();
    // If the user is not logged in redirect to the login page...
    if (!isset($_SESSION['loggedin']))
    {   header('Location: index.php');
        exit();
    }
//iconic19base Connection
require 'inc/connect.php';
require 'inc/head.php';
// We don't have the phone or email info stored in sessions so instead we can get the results from the database.
$stmt = $conn->prepare('SELECT student_id, name, name_bangla, photo ,phone, email, blood, district, address, address_bangla FROM iconic19 WHERE id = ?');
// In this case we can use the account ID to get the account info.
$stmt->bind_param('s', $_SESSION['id']);
$stmt->execute();
$stmt->bind_result($student_id, $name, $name_bangla, $photo, $phone, $email, $blood, $district, $address, $address_bangla);
$stmt->fetch();
$stmt->close();


//Get student_id from iconic19base
if(isset($_SESSION['id'])){
    $sql = "SELECT * FROM iconic19 WHERE id =" .$_SESSION['id'];
    $result = mysqli_query($conn, $sql);
    $row = mysqli_fetch_array($result);
}


//Update Information
if(isset($_POST['btn-update'])){
    $student_id = $_POST['student_id'];
    $name = $_POST['name'];
    $name_bangla = $_POST['name_bangla'];
    $blood = $_POST['blood'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $district = $_POST['district'];
    $address_bangla = $_POST['address_bangla'];
    $address = $_POST['address'];
    $update = "UPDATE iconic19 SET student_id='$student_id', name='$name',name_bangla='$name_bangla',blood='$blood',email='$email',phone='$phone',district='$district',address_bangla='$address_bangla',address='$address' WHERE id=". $_SESSION['id'];
    $up = mysqli_query($conn, $update);
    if(!isset($sql)){
        die ("Error $sql" .mysqli_connect_error());
    }
    else
    {
        header("location: home.php");
    }
}
?>

<!--Create Edit form -->
<!doctype html>
<html>
    <body>
      <div class="center-login">
        <h2 class='header-2'>১৯ এর ডায়েরি</h2>

<form id="edit" method="post">

<label>Student ID:</label><input type="text" name="student_id" placeholder="student_id" value=" <?=$student_id?>" maxlength="10" readonly><br/><br/>
<label>Name:</label><input type="text" name="name" placeholder="name" value="<?=$name?>" required><br/><br/>
<label>নাম:</label><input type="text" name="name_bangla" placeholder="name_bangla" value="<?=$name_bangla?>" required><br/><br/>
<label>Blood:</label><input type="text" name="blood" placeholder="blood" value="<?=$blood?>" required><br/><br/>
<label>Email:</label><input type="email" name="email" placeholder="email" value="<?=$email?>" required><br/><br/>
<label>Phone:</label><input type="tel" name="phone" placeholder="phone" value="<?=$phone?>" maxlength="11" required><br/><br/>
<label>District:</label><input type="text" name="district" placeholder="district" value="<?=$district?>" required><br/><br/>
<label>Address_bangla:</label><input type="text" name="address_bangla" placeholder="address_bangla" value="<?=$address_bangla?>" required></input>
<label>Address:</label><input type="text" name="address" placeholder="address" value="<?=$address?>" required></input>
<button type="submit" name="btn-update" id="btn-update" onClick="update()"><strong>Update</strong></button>
<a href="home.php"><button type="button" value="button">Cancel</button></a>
</form>
</div>
    </body>
<!-- Alert for Updating -->
<script>
function update(){
    var x;
    if(confirm("Updated ১৯ এর  ডায়েরি Sucessfully") == true){
        x= "update";
    }
}
</script>
</body>

<style>
#edit button[type="button"] {

    background: #b10e08;


  cursor: pointer;
  width: 100%;
  border: none;

  color: #FFF;
  margin: 0 0 5px;
  padding: 10px;
  font-size: 15px; 

}
.center-login {
  max-width: 400px;
  width: 100%;
    margin: 0 auto;
    position: unset;
    left: 0;
    top: 0;
    transform: unset;
    padding: unset;
    background: unset;
    border-radius: unset;


}

#edit input[type="text"],
#edit input[type="email"],
#edit input[type="tel"],
#edit input[type="url"],
#edit input[type="number"],
#edit textarea,
#edit button[type="submit"] {
  font: 400 12px/16px "Roboto", Helvetica, Arial, sans-serif;
}

#edit {
  background: #F9F9F9;
  padding: 25px;
   box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
       border-radius: 4px;
}

#edit h3 {
  display: block;
  font-size: 30px;
  font-weight: 300;
  margin-bottom: 10px;
}

#edit h4 {
  margin: 5px 0 15px;
  display: block;
  font-size: 13px;
  font-weight: 400;
}

fieldset {
  border: medium none !important;
  margin: 0 0 10px;
  min-width: 100%;
  padding: 0;
  width: 100%;
}

#edit input[type="text"],
#edit input[type="email"],
#edit input[type="tel"],
#edit input[type="url"],
#edit input[type="number"],
#edit textarea {
  width: 100%;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #FFF;
  margin: 0 0 5px;
  padding: 10px;
}

#edit input[type="text"]:hover,
#edit input[type="email"]:hover,
#edit input[type="tel"]:hover,
#edit input[type="url"]:hover,
#edit input[type="number"]:hover,
#edit textarea:hover {
  -webkit-transition: border-color 0.3s ease-in-out;
  -moz-transition: border-color 0.3s ease-in-out;
  transition: border-color 0.3s ease-in-out;
  border: 1px solid #aaa;
}

#edit textarea {
  height: 100px;
  max-width: 100%;
  resize: none;
}

#edit button[type="submit"] {
  cursor: pointer;
  width: 100%;
  border: none;
  background: #4CAF50;
  color: #FFF;
  margin: 0 0 5px;
  padding: 10px;
  font-size: 15px;
}

#edit button[type="submit"]:hover {
  background: #43A047;
  -webkit-transition: background 0.3s ease-in-out;
  -moz-transition: background 0.3s ease-in-out;
  transition: background-color 0.3s ease-in-out;
}

#edit button[type="submit"]:active {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.copyright {
  text-align: center;
}

#edit input:focus,
#edit textarea:focus {
  outline: 0;
  border: 1px solid #aaa;
}

::-webkit-input-placeholder {
  color: #888;
}

:-moz-placeholder {
  color: #888;
}

::-moz-placeholder {
  color: #888;
}

:-ms-input-placeholder {
  color: #888;
}

</style>

</html>
...