Hello NogDog
Replacing line 6 with
$post_id = (isset($_POST["post_id"])) ? $_POST["post_id"] : "";
and running it via link from index.php returns:
Array
(
)
going to check for post_id
post_id check failed, I got passed for the post_id
Notice: Undefined variable: myposts in /Library/WebServer/Documents/test/post.php on line 71
Notice: Undefined variable: myposts in /Library/WebServer/Documents/test/post.php on line 148
Notice: Undefined variable: mycomments in /Library/WebServer/Documents/test/post.php on line 170
lines 71, 148 and 170 are the usual:
71 if ($myposts) {
148 if ($myposts) {
170 if($mycomments) {
Doing the same with:
$post_id = (isset($_GET["post_id"])) ? $_GET["post_id"] : "";
returns:
Array
(
)
going to check for post_id
post_id is set with 7SELECT post_id, title, post, DATE_FORMAT(postdate, '%e %b %Y at %H:%i') AS dateattime FROM posts WHERE post_id=7 LIMIT 1
Array
(
[0] => 7
[post_id] => 7
[1] => debug
[title] => debug
[2] => testing posts.php
[post] => testing posts.php
[3] => 2 Aug 2007 at 00:14
[dateattime] => 2 Aug 2007 at 00:14
)
On attempting to submit a comment both return:
Array
(
)
going to check for post_id
post_id check failed, I got passed for the post_id
Notice: Undefined variable: myposts in /Library/WebServer/Documents/test/post.php on line 71
Notice: Undefined variable: myposts in /Library/WebServer/Documents/test/post.php on line 148
Notice: Undefined variable: mycomments in /Library/WebServer/Documents/test/post.php on line 170
The code for the add a comment form is:
<form method="post" action="<?php echo $_SERVER["PHP_SELF"] ?>">
<input type="hidden" name="post_id" value="<?=$post_id ?>" />
<input type="hidden" name="posttitle" value="<?=$title ?>" />
<h4>add a comment:</h4>
<?php
if (isset($message)) {
echo "<p>".$_POST["message"]."</p>";
}
?>
<p>name: <br /><input name="name" type="text" /></p>
<p>email: <br /><input name="email" type="text" /></p>
<p>website: <br /><input name="website" type="text" /></p>
<p>comment: <br /><textarea name="comment" cols="20" rows="10"></textarea></p>
<p class="align"><input type="submit" name="postcomment" value="post comment" /></p>
</form>
So I think this means I'm using the post method.
Hope that's got meaning!
Thanks for your input.
Hello Protato
With this code:
<?php
//open connection to database universal
include("../db_connect.php");
//get post_id from query string universal
6 $post_id = (isset($_REQUEST["post_id"]))?$_REQUEST["post_id"]:"";
//$post_id = $_POST['post_id'];
echo "<pre>";
print_r($_POST);
echo "</pre>";
echo "going to check for post_id<br>";
post.php?post_id=%3C?=$post_id%20?%3E&message=comment%20added. (posts.php after comment has been added and submitted) returns:
Array
(
)
going to check for post_id
post_id check failed, I got passed for the post_id
Notice: Undefined variable: myposts in /Library/WebServer/Documents/test/post.php on line 71
Notice: Undefined variable: myposts in /Library/WebServer/Documents/test/post.php on line 148
Notice: Undefined variable: mycomments in /Library/WebServer/Documents/test/post.php on line 170
So that's the output after submitting a comment.
Does it make sense?
Thanks again for your help
David