Page 1 of 1

prevent post from page refresh...help appreciated

Posted: Wed Sep 09, 2009 8:56 pm
by scarface222
Hey guys, quick question. I have a simple form that updates a database when clicked. Is there a way to prevent the post of it simply from page refresh have it triggered only by its input?

Code: Select all

 
echo '<form action="" method="POST" >
<input name="usernumber" value="$count" type="hidden">
<input type="submit" value="update">
</form>';
if (isset($_POST['usernumber']))
{
$query= "UPDATE topic SET user_number='$count'
WHERE td='$td'";
$query1=mysql_query($query);
}

Re: prevent post from page refresh...help appreciated

Posted: Wed Sep 09, 2009 9:54 pm
by Griven
I have no specific examples for you, but you'll want to read up on AJAX, which is what you would use to accomplish this.

http://en.wikipedia.org/wiki/Ajax_%28programming%29

Re: prevent post from page refresh...help appreciated

Posted: Thu Sep 10, 2009 6:19 pm
by scarface222
thanks man I'll give jquery post a try.

Re: prevent post from page refresh...help appreciated

Posted: Thu Sep 10, 2009 7:31 pm
by SimonMayer

Code: Select all

header("Location: index.php");
should do the trick.

Obviously replace index.php with the desired pagename.