Jump to content
  • 0

pomoc Pomoc s registrom v php


codex

Dotaz

Ahojte, dnes sa mi podarilo spraviť jednoduchý register v php, bez zabezpečenia. Prosím vás o pomoc s zabezpečením 

PS: som začiatočník

 

register.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Registrácia</title>
</head>
<body>
	<h1>Registrácia</h1>
	<form action="register.php" method="post">
		Meno <br>
		<input type="text" name="meno" placeholder="Prihlasovacie heslo"><br>
		Heslo <br>
		<input type="password" name="heslo" minlength="5" placeholder="***********"> <br>
		Email <br>
		<input type="text" name="email" placeholder="[email protected]"><br>
		<input type="submit" value="Registruj sa">
</form>
</body>
</html>

a toto je register.php

<?php 
$db = new PDO("mysql:host=localhost; dbname=skuska", "root", "");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$meno = $_POST['meno'];
$heslo = md5($_POST['heslo']);
$email = $_POST['email'];

$vloz = "INSERT INTO uzivatelia(meno, heslo, email)
			VALUES('$meno', '$heslo', '$email')";

try {
	$db->query($vloz);
} catch (PDOException $e) {
	echo $e->getMessage();
}

?>
Link to comment
Share on other sites

2 odpovědí na tuto otázku

Recommended Posts

  • 0


$meno = stripslashes($_POST['meno']);
$heslo = MD5($_POST['heslo']);
$email = stripslashes($_POST['email']);

$sql = "INSERT INTO uzivatelie (meno, heslo, email) VALUES (:meno, :heslo, :email)";
$query = $db->prepare($sql);
$query->execute(array(':meno' => $meno, ':heslo' => $heslo, ':email' => $email));

 

Link to comment
Share on other sites

  • 0

Šifrovat MD5 není až tak dobré když jde lehce dešifrovat. Není lepší použít např: SHA1.

Nebo zkusit použít složenou hašovací funkci: $hash = MD5(SHA1($heslo));

 

A nebo rovnou použít php fuknci na hash: ODKAZ

 

 

  • Líbí se mi to! (+1) 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...