0

I have a post a comment code that validates input but submits on page refresh. so i added session unique id to the form validation. but it won't let me post on any of the detail.php pages after i have posted on one(detail.php is a dynamic page that gets the records from my db) for example
www.mylink.com/detail.php?vtopic= 78 - this allows me to post on the article on 78
www.mylink.com/detail.php?vtopic= 79- doesn't allow me.
On my form page i already have a variable that gets vtopic
$p_name = $_GET and puts in my db.
So is there a way so that the session nows the $p_name so that it stop me commenting on other articles on the detail.php
todo is the hidden field, auto increment.

$todo = uniqid();
$_SESSION['todo'] = $todo;

$todo=$_POST['todo'];
if(empty($_POST['todo'])
      or empty($_SESSION['todo'])
      or $_POST['todo'] != $_SESSION['todo'])
   {
      echo " you have submitted form";
   } 


else{
validate form
}

Any help will be appreciated
or tell me a better way to stop form submission on refresh

Edited by tunde011: n/a

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by tunde011
0

Ensure that you send form to a different page (e.g. formhandler.php) - it's not a good idea to send forms to the same page anyway.

form.php (fill data/submit) -> formhandler.php (process data and return) -> form.php

0

Ensure that you send form to a different page (e.g. formhandler.php) - it's not a good idea to send forms to the same page anyway.

form.php (fill data/submit) -> formhandler.php (process data and return) -> form.php

Thanks, done it works now,

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.