jumpenjuhosaphat Posted December 28, 2006 Share Posted December 28, 2006 For some reason the following script isn't passing the hidden field to the php script. Any help would be greatly appreciated. I have looked on the net, and can't find anything wrong with my code. But for some reason, when I echo the hidden field, nothing comes up.[code]<?phpinclude('config.php');include('functions.php');if(!isset($_COOKIE[''])) { header("Location: http://www.fumbug.co.uk"); exit; }if(!isset($_POST['submitedit'])) {$content='<form method="POST" action="editcategory.php"><input type="hidden" name="editid" value="'.$row['id'].'"/><table><tr><td>Category Name:</td><td><input type="text" name="newname" value="'.$row['catname'].'"/></td></tr><tr><td>Category Description:</td><td><textarea name="newdescription">'.$row['description'].'</textarea></td></tr><tr><td></td><td><input type="submit" name="submitedit" value="Save"/></td></tr></table></form>'; }if(isset($_POST['submitedit'])) { $con=mysql_connect("localhost",$user,$password) or die("register.php connect error ".mysql_error()); mysql_select_db($database, $con); $query="UPDATE category SET catname='$_POST[newname]' && description='$_POST[newdescription]' WHERE id='$_POST[editid]'"; mysql_query($query);echo $_POST['editid'].$_POST['newname'].$_POST['newdescription'];// $childid=0;// include('popcat.php');// include('categoryform.php');// include('template.php'); }?>[/code] Link to comment https://forums.phpfreaks.com/topic/32021-solved-hidden-form-not-being-passed-to-php/ Share on other sites More sharing options...
fert Posted December 28, 2006 Share Posted December 28, 2006 are you sure $row['id'] has a value? Link to comment https://forums.phpfreaks.com/topic/32021-solved-hidden-form-not-being-passed-to-php/#findComment-148630 Share on other sites More sharing options...
jumpenjuhosaphat Posted December 28, 2006 Author Share Posted December 28, 2006 Yes. When I view the source for the page, the value is set at the number of the category that I am editing. The source looks like this:[code]<input type="hidden" name="editid" value="15"/>[/code]The other fields are being passed. When I echo the $_POST variables on the script page, the $_POST['newname'] and $_POST['newdescription'] appear, but not the hidden field($_POST['editid']). Link to comment https://forums.phpfreaks.com/topic/32021-solved-hidden-form-not-being-passed-to-php/#findComment-148632 Share on other sites More sharing options...
jumpenjuhosaphat Posted December 28, 2006 Author Share Posted December 28, 2006 I just got it figured out. I had originally set the hidden field up with: id="editid" as a typo, I fixed the typo by changing it to: name="editid". I just simply forgot to refresh the page before submitting, and that is why the variable wasn't being passed. Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/32021-solved-hidden-form-not-being-passed-to-php/#findComment-148635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.