Unstoppable Domains

[Resolved] [HELP] Inserting data into a MySQL table - Checking for duplicates

Spaceship Spaceship
Watch

Swefx

Established Member
Impact
2
[HELP]Inserting data into a MySQL table - Checking for duplicates

Hi,

I've made a flash game with a highscore table. I used PHP and MySQL for this. The only thing is that if you refresh a certain page it makes another entry in the database. I want it to check to see whether there is already a entry with that name and score. Here's my code:

<?php
// set your infomation.
$dbhost='I bet';
$dbusername='you would';
$dbuserpass='like to know';
$dbname='this you hacker!';

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);

if (!mysql_select_db($dbname)) die(mysql_error());

$score = secretinfo;
$name = notforyoureyes;

$query = "INSERT INTO highscore (gameid, name, score) VALUES('$gameid','$name','$score')";
mysql_query($query) or die(mysql_error());
echo "Highscore inserted successfully, view highscore table <a href='highscore.php?game=$gameid' target'_self'>here.</a>";
?>

Rep will be given to person modifies this code for me :]
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
the simplest solution: Do not even offer them to click here or there , just forward them to the score page,
PHP:
header("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
from php.net/header
 
0
•••
It works! Cheers! B-)
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer

We're social

Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back