Hello everybody:
i have this php code that access the database directly and add ammos to specific player wich i can use a form using steamID and amount of ammos to edit it directly from database.
please look on this code if something wrong and help me for fix it and for be working 100% :)
thanks.
i have this php code that access the database directly and add ammos to specific player wich i can use a form using steamID and amount of ammos to edit it directly from database.
please look on this code if something wrong and help me for fix it and for be working 100% :)
thanks.
Код:
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
// define variables and set to empty values
$steamidErr = $ammos = "";
$steamid = $ammos = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["steamid"])) {
$steamidErr = "SteamID is required";
} else {
$steamid = test_input($_POST["steamid"]);
}
}
if (empty($_POST["ammos"])) {
$emailErr = "Ammos are required";
} else {
$email = test_input($_POST["ammos"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>Enter SteamID and ammount to add :</h2>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
SteamID: <input type="text" name="steamid" value="<?php echo $steamid;?>">
<span class="error">* <?php echo $steamidErr;?></span>
<br><br>
Ammos: <input type="text" name="ammos" value="<?php echo $ammos;?>">
<span class="error">* <?php echo $ammosErr;?></span>
<br><br>
<input type="submit" name="submit" value="Add Ammos">
</form>
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "UPDATE Table SET ammos+='$ammos' WHERE steamid='$steamid';
if (mysqli_query($conn, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
mysqli_close($conn);
?>
</body>
</html>
Код:
<?php
$user = $_POST['user'];
$pass = $_POST['pass'];
if($user == "admin"
&& $pass == "admin")
{
include("secure.html");
}
else
{
if(isset($_POST))
{?>
<form method="POST" action="secure.php">
User <input type="text" name="user"></input><br/>
Pass <input type="password" name="pass"></input><br/>
<input type="submit" name="submit" value="Go"></input>
</form>
<?}
}
?>
Вложения
-
13.2 KB Просмотры: 34