Jump to content
Larry Ullman's Book Forums

Post Method To Update Record Not Working


Recommended Posts

php version 5.3.1

mysql 5.1.41

xampp 1.7.3

 

 

Hi all,

 

I am trying to update a record using the edit_user principle but to no success. My check indicates that my hidden parameter(dailydelivery_id) is not passed. can you please check if there is something wrong with the following code summary?

 

<form method="post" action="edit_dailydelivery.php">

.

.

.

<p><input type="submit" name="submit" value="UPDATE" /></p>

<input type="hidden" name="submitted" value="TRUE"/>

<input type="hidden" name="dailydelivery_id" value="' . $id . '" />

 

I then try to get hidden parameter using:

// Check for a valid dailydelivery ID, through GET or POST:

if ( (isset($_GET['dailydelivery_id'])) && (is_numeric($_GET['dailydelivery_id'])) ) { // From view_dailydeliveries.php

$id = $_GET['dailydelivery_id'];

} elseif ( (isset($_POST['dailydelivery_id'])) && (is_numeric($_POST['dailydelivery_id'])) ) { // Form submission.

$id = $_POST['dailydelivery_id'];

} else { // No valid ID, kill the script.

echo '<p class="error">This page has been accessed in error.</p>';

include ('includes/footer.html');

exit();

}

and i get the error "This page has been accessed in error."

It worth mentioning that the get works perfectly.

Link to comment
Share on other sites

Like Larry said you're not actually echoing out the value of $id. Everywhere else on your form when you've broke back into PHP tags to print it e.g.

 

value="<?php echo $main_row['variance'] ?>"

 

But when you've tried to print the value of $id you've simply done:

 

<input type="hidden" name="dailydelivery_id" value="' . $id . '"/>

 

That line is outside any PHP tags and therefore being treated as HTML only. Change to:

 

<input type="hidden" name="dailydelivery_id" value="<?php echo $id; ?>"/>

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...