Jump to content

[SOLVED] hidden form not being passed to php


jumpenjuhosaphat

Recommended Posts

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]<?php
include('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]
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']).
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.