امیرملکوتی
3 سال پیش توسط امیرملکوتی مطرح شد
0 پاسخ

مشکل در ویرایش اطلاعات mysqliدر php

سلام دوستان در کد زیر اطلاعات ویرایش نمیشه مشکل از کجاست؟؟
@hesammousavi

<?php

$link = mysqli_connect('localhost:3306' , 'root' , '');
if(! $link) {
    echo 'could not connect : ' . mysqli_connect_error();
    exit;
}

mysqli_select_db($link , 'customer');

$stmt = mysqli_prepare($link , "select * from customer");
$id = (string) $_GET['name'];
mysqli_stmt_bind_param($stmt , 's' , $id);
mysqli_stmt_execute($stmt);

$result = mysqli_stmt_get_result($stmt);

// if($result->num_rows == 0) {
//     header("Location: https://soft98.ir");
//     return;
// }

$user = mysqli_fetch_assoc($result);

if($_SERVER['REQUEST_METHOD'] == 'GET'  && isset($_GET['name']) && isset($_GET['phone']) && isset($_GET['kala']) && isset($_GET['description'])&& isset($_GET['check']) && isset($_GET['number'])&& isset($_GET['Price']) && isset($_GET['get_price']) && null !=($_GET['name']) && null !=($_GET['phone']) && null !=($_GET['kala']) && null !=($_GET['description'])&& null !=($_GET['check']) && null !=($_GET['number'])&& null !=($_GET['Price']) && null !=($_GET['get_price'])) {
    $name = $_GET['name'] ;
    $phone = $_GET['phone'] ;
    $kala = $_GET['kala'] ;
    $des = $_GET['description'] ;
    $check = $_GET['check'] ;
    $number = $_GET['number'] ;
    $Price = $_GET['Price'] ;
    $get_price = $_GET['get_price'] ;
    $date = $_GET['date'] ;
    $hour = $_GET['get_hour'] ;
    $stmt = mysqli_prepare($link , "update customer set name = ?, phone = ?, get_date = ? , get_hour = ?, kala = ? , Price = ? ,number = ?, description = ? , checked = ? where name = ?");
    mysqli_stmt_bind_param($stmt , 'sssssiisss' ,  $name , $phone , $date ,$hour , $kala ,$Price , $number, $des , $check , $user['name']);
    mysqli_stmt_execute($stmt);

    if( mysqli_affected_rows($link) ) {
        header("Location: http://roocket.ir");
        return;
    }
}
?>

<html dir="rtl">
    <head>
        <title>Register Page</title>
    </head>
    <body>
        <h3>User Edit</h3>
        <br>
        <form action="./edit.php" method="get">
            <label for="">نام </label>
            <input type="text" name="name" value="<?= $user['name'] ?>"><br>
            <label for="">شماره تماس کاربر</label>
            <input type="text" name="phone" value="<?= $user['phone'] ?>"><br>
            <label for="">تاریخ </label>
            <input type="text" name="get_date" value="<?= $user['get_date'] ?>"><br>
            <label for="">ساعت</label>
            <input type="text" name="get_hour" value="<?= $user['get_hour'] ?>"><br>
            <label for="">نوع کالا</label>
            <input type="text" name="kala" value="<?= $user['kala'] ?>"><br>
            <label for="">قیمت کالا</label>
            <input type="text" name="Price" value="<?= $user['Price'] ?>"><br>
            <label for="">تعداد کالا</label>
            <input type="text" name="number" value="<?= $user['number'] ?>"><br>
            <label for="">وضعیت خرید</label>
            <input type="text" name="check" value="<?= $user['checked'] ?>"><br>
            <label for="">توضیحات</label>
            <input type="text" name="description" value="<?= $user['description'] ?>"><br>
            <button type="submit">ثبت ویرایش</button>
        </form>
    </body>
</html>