-
Post issues
Hi,
I've currently got the following code:
PHP Code:
echo "<form name=\"AdminStuff\" action=\"newPost.php\" method=\"POST\">\n";
echo "<div class=\"hr\"> <hr /> </div>\n";
echo "<h1>" . $heading . "</h1>\n";
echo "<p>" . $content . "</p>\n";
echo "<span class=\"postinfo\"> Posted by " . $poster . " on " . $date . "\n";
echo "<input type=\"hidden\" name=\"heading\" value=\"$heading\">\n";
echo "<input type=\"hidden\" name=\"content\" value=\"$content\">\n";
echo "<input type=\"hidden\" name=\"postID\" value=\"$postID\">\n";
echo " [ <a href=\"newPost.php\" onClick=\"AdminStuff.submit(); return false;\">Edit</a>\n";
echo " | <a href=\"removePost.php\" onClick=\"AdminStuff.submit(); return false;\">Remove</a> ]\n";
echo "</span>\n";
echo "</form>\n";
Right now, this generates the HTML as expected.. with the three hidden fields with the right information.
However, in newPost.php, the $_POST array is empty.
The code for newPost.php is as follows:
PHP Code:
echo "<form method=\"post\" action=\"generatePost.php\" action=\"POST\">";
echo "<textarea name=\"heading\" cols=\"40\" rows=\"1\">";
echo $_POST['heading'];
echo "</textarea><br>";
echo "<textarea name=\"body\" cols=\"40\" rows=\"5\">";
echo $_POST['content'];
echo "</textarea><br>";
echo "<input type=\"submit\" value=\"Submit\" />";
echo "<input type=\"hidden\" value=\"" . $_POST['postID'] . "\">";
echo "</form>";
Any ideas? If there's any easier way, please let me know. I need the link to be a hyperlink, and to send the data with POST (not GET).
Thanks
-Rob
-
Re: Post issues
Hi,
Try putting both the html and the php in the one file and see if that helps!
-
Re: Post issues
you do not need to do what Nightwalker83 suggested.
you're technically submitting your form via a link, and so if your browser is just going to newPost.php instead of submitting to it, this would be your problem. just use a submit button.
HTML Code:
<input type="submit" name="edit" value="Edit" />
<input type="submit" name="remove" value="Remove" />
you could check if $_POST['edit'] or $_POST['remove'] exist and then either edit or remove the post accordingly.
-
Re: Post issues
double post an hour later, somehow. whoops. delete this?