Kodları bir arkadaş ile birlikte çözdüm.
Kodlar;
<?php
$servername = "localhost";
$username = "rijitsuc_coffee";
$password = "asd84dcpolice";
$dbname = "rijitsuc_coffee";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id, name, score FROM scores";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "" . $row["id"]. "" . $row["name"]. " " . $row["score"]. "<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?><?php
$db = "rijitsuc_coffee";//Your database name
$dbu = "rijitsuc_coffee";//Your database username
$dbp = "asd84dcpolice";//Your database users' password
$host = "localhost";//MySQL server - usually localhost
$conn = mysqli_connect($host,$dbu,$dbp);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if(isset($_GET['name']) && isset($_GET['score'])){
//Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
$name = strip_tags(mysqli_real_escape_string($_GET['name']));
$score = strip_tags(mysqli_real_escape_string($_GET['score']));
$sql = mysqli_query("INSERT INTO `$db`.`scores` (`id`,`name`,`score`) VALUES ('','$name','$score');");
if($sql){
//The query returned true - now do whatever you like here.
echo 'Your score was saved. Congrats!';
}else{
//The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
echo 'There was a problem saving your score. Please try again later.';
}
}else{
echo 'Your name or score wasnt passed in the request. Make sure you add ?name=name=" & pointsend.Text & "&score=" & yuksekpuan';
}
mysqli_close($conn);
?>