prevent post from page refresh...help appreciated

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
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

prevent post from page refresh...help appreciated

Post 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);
}
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

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

Post 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
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

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

Post by scarface222 »

thanks man I'll give jquery post a try.
SimonMayer
Forum Commoner
Posts: 32
Joined: Wed Sep 09, 2009 6:40 pm

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

Post by SimonMayer »

Code: Select all

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

Obviously replace index.php with the desired pagename.
Post Reply