Page 1 of 1

commenting form

Posted: Mon Oct 03, 2016 1:36 pm
by marmahan
Hi,
I'm trying to learn php so I'm developing a simple website, this website shows some posts, it only shows part of a post and when the user hits "read more" button we go to the details.php page, I'm trying to create a commenting form.
For example the user hits post number 3 then url would be:

Code: Select all

http://localhost/MYCMS/details.php?post=3

the code for the form is:
We are now in a page called details

Code: Select all

     
<form method="post" action="details.php?post=<?php echo $post_id; ?>">
       <tr><td>Name </td><td><input type="text" name="name"></td></tr>
       <tr><td>Email </td><td><input type="text" name="email"></td></tr>
       <tr><td>Comment</td><td><textarea name="comment" rows="20" cols="35"></textarea></td></tr>
       <tr><td align="center" colspan="2"><input type='submit' name='submit' value='post comment' /></td></tr>  
     </form>
    </table>
$post_id is the number of the post which I got from the previous page when the user hit "read me"
This variable contains the right number as i printed it out.
whenever i hit submit I get this url and 404 error:

Code: Select all

http://localhost/MYCMS/result.php?searchbox=&name=&email=&comment=&submit=post+comment
I don't have any page called result.php, could someone please explain to me why I'm being directed into a page that doesn't exist?
Even if i leave the action blank I get the same result.
Thanks

Re: commenting form

Posted: Mon Oct 03, 2016 4:48 pm
by Christopher
Do you have another form on the page? It looks like the search form is being submitted instead of your form.

Re: commenting form

Posted: Tue Oct 04, 2016 10:41 am
by marmahan
I have another form but not in this page. Thanks for the hint.

Re: commenting form

Posted: Tue Oct 04, 2016 4:53 pm
by Christopher
So what is posting to "result.php?searchbox=&name=&email=&comment=&submit=post+comment" ?

Re: commenting form

Posted: Tue Oct 04, 2016 6:04 pm
by Celauran
This form has method="post" but that result.php?etc is clearly a GET request. JS running interference?

Re: commenting form

Posted: Thu Oct 06, 2016 7:45 am
by marmahan
This form has method="post" but that result.php?etc is clearly a GET request. JS running interference?
Would you explain a bit more please, what should i do? what's actually happening?

Re: commenting form

Posted: Thu Oct 06, 2016 11:21 am
by Celauran
I don't know what's actually happening. The form code you posted and the results you're getting don't line up, so some code that has not yet been shared is responsible.

Re: commenting form

Posted: Thu Oct 06, 2016 5:32 pm
by Christopher
marmahan wrote:
This form has method="post" but that result.php?etc is clearly a GET request. JS running interference?
Would you explain a bit more please, what should i do? what's actually happening?
The impression I am getting is that here is a Javascript handler for the form submit event defined somewhere. It looks like the search box. So when you click the submit button some Javascript somewhere is handling the submit.