Hi there,
I'm having a bit of a problem passing a variable from a form to a php script and could use some help.
I hope this makes sense: The problem occurs when the script doesn't recognise the name of the text-area (which is a unique name that changes each time). It is unique due to a randomly generated number (which is also passed to the script and working). I've tried using GET methods of passing the $id and also hidden field (POST) methods. The $id is passed both times, but when used to retrieve the text-area content it throws the error:
Notice: Undefined index: editcontent2894864c9b2d11c11a91.56512640 in C:\wamp\www\intergr8\backstage\backstage.php on line 126
here is the 'getNews.php' script:
else if($action=="edit") // EDIT ARTICLE
{
while($row = mysql_fetch_array($result))
{
$id = uniqid(rand(100000,999999),true); //ckeditor ID
echo "<br />Edit your article and click confirm to change.<br /><br />";
echo "<form action='backstage.php?editidnum=".$id."' method='post' enctype='multipart/form-data'>
<input type='hidden' value='".$id."' name='idvalue' />
<table>";
if(isset($message))
{
echo "<tr>";
foreach($message as $value)
{
echo "<td colspan='2' class='error'>".$value."</td>";
}
echo "</tr>";
unset($message);
}
else if(isset($_GET['success']))
{
echo "<td colspan='2' class='success'>*Thankyou. Your article was successfully posted!</td>";
}
echo"<tr>
<td>Title:</td>
<td><input type='text' name='title'
value='".$row['news_title']."'";
echo "/></td>
</tr>
<tr>
<td>Image:</td>
<td><input type='file' name='downloadfile".$id."' /></td>
</tr>
<tr>
<td colspan='2'><textarea class='textArea' name='editcontent".$id."'>".$row['news_content']."</textarea></td>
</tr>
<tr>
<td colspan='2' id='alignRight'><input type='image' value='edit' name='edit' src='images/popup_10.png' /><br />
<br />
</td>
</tr>
</table>
<script type='text/javascript'>
CKEDITOR.replace( 'editcontent".$id."',
{
width: '840px',
height: '260px',
toolbar : 'News',
});
</script>
</form>";
}
}
And here is the relevant script from 'backstage.php':
//EDIT post from form
if(isset($_POST['edit']) && $_POST['edit']=="edit")
{
$id = $_GET['editidnum'];
$downloadPost = 'editdownloadfile'.$id;
$editContent = "editcontent".$id;
echo $title = $_POST['title'];
echo $content = $_POST[$id]; //This line gives an error
I've been working on this problem for hours and hours. And I think it might be something simple for someone else to spot. So any help would be kindly appreciated.
Cheers
Danny