2016-11-01 4 views
0

Ich möchte das Kundenregistrierungsformular aktualisieren. Jedes Mal, wenn ich versuchte, nach der Bearbeitung der Daten zu speichern, bringt es Fehler. Notice: Undefined index: prc_id in C: \ wamp64 \ www \ customer \ edit.php on line 6 Call StackFehler beim Speichern des Kundenformulars

Zeitspeicherfunktion Ort

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

Hinweis (!): Undefined index: prc_name in C: \ wamp64 \ www \ customer \ edit.php auf Linie 7 Call Stack

Zeitfunktion Memory Location

1 0,0007 2516 96 {main}() ... \ edit.php: 0

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

Zeitspeicherfunktion Ort

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

Hinweis (!): Undefined index: prc_phone in C: \ wamp64 \ www \ customer \ edit.php auf Linie 9 Call Stack

Zeitfunktion Memory Location

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

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

Zeitspeicherfunktion Ort

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

Bitte, jede Hilfe.

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"); 
?> 
+0

Ihr POST prc_id fehlt – MuthaFury

+0

Ändern Sie Ihre editform.php on line $ id = $ _ GET ['prc_id']; Ersetzen durch $ id = $ _ GET ['id']; es ist in Ordnung –

+0

ODER wenn nicht ändern Sie editform.php so andere Option ändern Sie Ihre HTML-Zeile Edit ersetzen durch Edit

Antwort

0

Ihr Formular enthält keinen Namen mit 'prc_id'. In Ihrem Fall lautet der Name "ids". Ersetzen Sie es durch 'prc_id'.

+0

@bran van Rijswjk. Vielen Dank –

1

Versuchen Sie, $id = $_GET['prc_id']; zu $id = $_GET['id']; zu ändern.

Verwandte Themen