drgwsx8405 2016-11-01 10:26
浏览 21

保存客户编辑的表单时出错

I want to update customer registration form. Anytime i tried to save after editing the data, it brings out error. Notice: Undefined index: prc_id in C:\wamp64\www\customer\edit.php on line 6 Call Stack

Time Memory Function Location

1 0.0007 251696 {main}( ) ...\edit.php:0

( ! ) Notice: Undefined index: prc_name in C:\wamp64\www\customer\edit.php on line 7 Call Stack

Time Memory Function Location

1 0.0007 251696 {main}( ) ...\edit.php:0

( ! ) Notice: Undefined index: prc_email in C:\wamp64\www\customer\edit.php on line 8 Call Stack

Time Memory Function Location

1 0.0007 251696 {main}( ) ...\edit.php:0

( ! ) Notice: Undefined index: prc_phone in C:\wamp64\www\customer\edit.php on line 9 Call Stack

Time Memory Function Location

1 0.0007 251696 {main}( ) ...\edit.php:0

( ! ) Notice: Undefined index: prc_gender in C:\wamp64\www\customer\edit.php on line 10 Call Stack

Time Memory Function Location

1 0.0007 251696 {main}( ) ...\edit.php:0

Please, any help.

index.php

<?php
  include_once('connect.php');
  $result = $db->prepare("SELECT * FROM p_r_customers ORDER BY prc_id DESC");
  $result->execute();
?>
  <table border="1" cellspacing="0" cellpadding="2" >
        <tr>
        <th>ID</th>
            <th>Name</th>
            <th>Email</th>
            <th>Phone</th>
        <th>Gender</th>
        <th>Birthday Day</th>
        <th>Birthday Month</th>
        <th>Age Group</th>
        <th>Card ID</th>
        <th>Password</th>
        <th>Country</th>
        <th>State</th>
        <th>rand</th>
        </tr>
    <tbody>
        <?php
            for($i=0; $row = $result->fetch(); $i++){
        ?>
        <tr class="record">
            <td><?php echo $row['prc_id']; ?></td>
            <td><?php echo $row['prc_name']; ?></td>
            <td><?php echo $row['prc_email']; ?></td>
        <td><?php echo $row['prc_phone']; ?></td>
            <td><?php echo $row['prc_gender']; ?></td>
            <td><?php echo $row['prc_dob_day']; ?></td>
        <td><?php echo $row['prc_dob_month']; ?></td>
            <td><?php echo $row['prc_age_group']; ?></td>
            <td><?php echo $row['prc_card']; ?></td>
        <td><?php echo $row['prc_password']; ?></td>
            <td><?php echo $row['prc_country']; ?></td>
            <td><?php echo $row['prc_state']; ?></td>
        <td><?php echo $row['prc_rand']; ?></td>
            <td><a href="editform.php?id=<?php echo $row['prc_id']; ?>"> Edit </a></td>
        </tr>
        <?php
            }
       ?>
    </tbody>
    </table>

editform.php

<?php
        include_once('connect.php');
        $id=$_GET['id'];
        $result = $db->prepare("SELECT * FROM p_r_customers WHERE prc_id= :userid");
        $result->bindParam(':userid', $id);
        $result->execute();
        for($i=0; $row = $result->fetch(); $i++){
    ?>
    <form action="edit.php" method="POST">
    <input type="hidden" name="ids" value="<?php echo $id; ?>" />
    Name<br>
    <input type="text" name="name" value="<?php if(isset($_row)){ echo $_row['prc_name'];} ?>" /><br>
    Email<br>
    <input type="text" name="email" value="<?php if(isset($_row)){ echo $_row['prc_email'];} ?>" /><br>
    Phone<br>
    <input type="text" name="phone" value="<?php if(isset($_row)){ echo $_row['prc_phone'];} ?>" /><br>
    Gender<br>
    <input type="text" name="gender" value="<?php if(isset($_row)){ echo $_row['prc_gender'];} ?>" /><br>
    Birthday Day<br>
    <input type="text" name="dob_day" value="<?php if(isset($_row)){ echo $_row['prc_dob_day'];} ?>" /><br>
    Birthday Month<br>
    <input type="text" name="dob_month" value="<?php if(isset($_row)){ echo $_row['prc_dob_month'];} ?>" /><br>
    Age group<br>
    <input type="text" name="age_group" value="<?php if(isset($_row)){ echo $_row['prc_age_group'];} ?>" /><br>
    Card ID<br>
    <input type="text" name="card" value="<?php if(isset($_row)){ echo $_row['prc_card'];} ?>" /><br>
    Password<br>
    <input type="text" name="password" value="<?php if(isset($_row)){ echo $_row['prc_password'];} ?>" /><br>
    Country<br>
    <input type="text" name="country" value="<?php if(isset($_row)){ echo $_row['prc_country'];} ?>" /><br>
    State<br>
    <input type="text" name="state" value="<?php if(isset($_row)){ echo $_row['prc_state'];} ?>" /><br>
    Rand<br>
    <input type="text" name="rand" value="<?php if(isset($_row)){ echo $_row['prc_rand'];} ?>" /><br>
    <input type="submit" value="Save" />
    </form>
    <?php
        }
  ?>

edit.php
<?php
include_once('connect.php');

// new data

$id = $_POST['prc_id'];
$name = $_POST['prc_name'];
$email = $_POST['prc_email'];
$phone = $_POST['prc_phone'];
$gender = $_POST['prc_gender'];
$dob_day = $_POST['prc_dob_day'];
$dob_month = $_POST['prc_dob_month'];
$age_group = $_POST['prc_age_group'];
$card = $_POST['prc_card'];
$password = $_POST['prc_password'];
$country = $_POST['prc_country'];
$state = $_POST['prc_state'];
$rand = $_POST['prc_rand'];

// query
$sql = "UPDATE p_r_customers
        SET prc_name=?, prc_email=?, prc_phone=?, prc_gender=?, prc_dob_day=?, prc_dob_month=?,
        prc_age_group=?, prc_card=?, prc_password=?, prc_country=?, prc_state=?, prc_rand=?
        WHERE prc_id=?";
$q = $db->prepare($sql);
$q->execute(array($id,$name,$email,$phone,$gender,$dob_day,$dob_month,$age_group,$card,$password,$country,$state,$rand));
header("location: index.php");
 ?>
  • 写回答

2条回答 默认 最新

  • doushan9415 2016-11-01 10:33
    关注

    Your form doesn't contain a name with 'prc_id'. In your case, its name is 'ids'. Replace it with 'prc_id'.

    评论

报告相同问题?

悬赏问题

  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多