Hello one and all.
Despite having been registered for ages, this is my first post. I've always tried to search the forums and read stuff before posting as I know places like this can get clogged up with the same old things.
Anyway, I can't find anything specific to my cause so I though I'd post.
I'm pretty much a total amateur at PHP as I'm a designer first and foremost - as such I'm slow to learn and everything I do has to be learnt with a certain amount of trial and error.
Anyway, I have a flash game which works Ok, and I'm submitting scores to a database which can then be displayed in a PHP page. Basic stuff for most of you I imagine.
My problem is security. If this project becomes even moderately popular (and I class that as people outside the circle of my immediate friends), I want reassurance that some nutcase is not going to start doing weird things to any of my stuff, as it were.
Like I say, it's simple enough stuff:
<?php
$Host = "localhost";
$User = "username";
$Password = "password";
$db = "database";
$Link = mysql_connect ($Host, $User, $Password);
mysql_select_db($db, $Link)
or die("<br>Error connecting to database".mysql_error());
$name = trim($name);
$email = trim($email);
mysql_query("INSERT into table values(
'$total',
'$name',
'$email')")
or die("<br>Error submitting data".mysql_error());
mysql_close ($Link);
$adminaddress = "mail@mydomain.co.uk";
mail("mail@mydomain.co.uk","New submission", "Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$adminaddress");
?>
is the code for submitting the scores and on the page displaying the scores there is:
<?php
$Host = "localhost";
$User = "username";
$Password = "password";
$db = "database";
$table = "table";
$Link = mysql_connect ($Host, $User, $Password);
mysql_select_db ($db) or die ("Cannot connect to database");
$query = "SELECT * FROM $table ORDER BY total DESC";
$result = mysql_db_query ($db, $query, $Link);
mysql_close ($Link);
?>
with this code in the body of the HTML:
<?php
while($row=mysql_fetch_array($result)){
echo $row['total']," ", $row['name'], "<br>";
}
?>
That's probably as easy to hack into as a paper bag, I just don't know. Which bits need to be secure? All of them?
Any help would be much appreciated, whether it be direct help or a push in the right direction.
Thanks.