commenting form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
marmahan
Forum Newbie
Posts: 3
Joined: Mon Oct 03, 2016 1:23 pm

commenting form

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: commenting form

Post by Christopher »

Do you have another form on the page? It looks like the search form is being submitted instead of your form.
(#10850)
marmahan
Forum Newbie
Posts: 3
Joined: Mon Oct 03, 2016 1:23 pm

Re: commenting form

Post by marmahan »

I have another form but not in this page. Thanks for the hint.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: commenting form

Post by Christopher »

So what is posting to "result.php?searchbox=&name=&email=&comment=&submit=post+comment" ?
(#10850)
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: commenting form

Post by Celauran »

This form has method="post" but that result.php?etc is clearly a GET request. JS running interference?
marmahan
Forum Newbie
Posts: 3
Joined: Mon Oct 03, 2016 1:23 pm

Re: commenting form

Post 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?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: commenting form

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: commenting form

Post 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.
(#10850)
Post Reply