Nu reusesc sa duc la capat acest script, va rog un pic de ajutor, multumesc.
Cod: Selectaţi tot
<!DOCTYPE html>
<html>
<body>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if(isset($_POST['submit']) && $_POST['submit']=="Adauga cont de joc" && isset($_POST['login']) && isset($_POST['password']) && isset($_POST['email'])) {
if(isset($_POST['login'])) {echo "<h3>cont: " . $_POST['login'] . "</h3><br>";}
if(isset($_POST['password'])) {echo "<h3>parola: " . $_POST['password'] . "</h3><br>";}
if(isset($_POST['email'])) {echo "<h3>email: " . $_POST['email'] . "</h3><br>";}
echo '<h1>Acum vezi singura data aceste date! Scrie-le pentru ca nu pot fi recuperate!</h1>';
$host = 'localhost';
$db = 'account';
$user = 'project';
$password = 'HWzGt5jq5p36Vn42';
$dsn = "mysql:host=$host;dbname=$db;charset=UTF8";
try {
$dbh = new PDO($dsn, $user, $password);
if ($dbh) {
echo "Procesez datele pentru a fi stocate in $db";
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $dbh->prepare('SELECT COUNT(*) FROM account WHERE login = ?');
$sth->bindValue(1, S_POST['login'], PDO::PARAM_STR);
if ($sth->execute() === true) {
if ($sth->fetchColumn() < 1) {
$sth = $dbh->prepare('INSERT INTO account (login, password, email, ip) VALUES(?, ?, ?, ?)');
$sth->bindValue(1, S_POST['login'], PDO::PARAM_STR);
$sth->bindValue(2,PASSWORD(S_POST['password']), PDO::PARAM_STR);
$sth->bindValue(3, S_POST['email'], PDO::PARAM_STR);
$sth->bindValue(4, S_SERVER['REMOTE_ADDR'], PDO::PARAM_STR);
if ($sth->->execute() === true) {
$success = 'Contul tau a fost creat!';
}
else {$error = 'Nu pot introduce aceste date!';}
else {$error = 'Nu ai nevoie de cont nou, ai deja unul!';}
else {$error = 'Nu pot procesa cererea!';}
}
} catch (PDOException $e) {echo $e->getMessage();}
}
$dbh = null;
}
}
else {
?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" accept-charset="UTF-8" class="search-form search-block-form">
<label for="login">cont</label><br> <input type="text" id="login" name="login" placeholder="adauga numele contului" value="" maxlength="100" required=""><br>
<label for="password">parola</label><br> <input type="password" id="password" name="password" placeholder="adauga parola contului" value="" maxlength="100" required=""><br>
<label for="email">email</label><br> <input type="email" id="email" name="email" placeholder="adauga email valabil" value="" maxlength="100" required=""><br>
<input type="submit" name ="submit" value="Adauga cont de joc">
</form>
<?php
}
?>
</body>
</html>
