Jump to content

Inregistrarea Utilizatorilor


skyler_sdf

Recommended Posts


//acest fisier verifica daca avem date transmise, apoi preia numele, username-ul si parola utilizatorului din variabila superglobala $_POST si executa un query MySQL de tip INSERT pentru a salva datele in tabela users 

//(Id-ul lipseste din query deoarece este incrementat automat). Ca metoda de securitate, parola este encodata utilizand functia md5():


<?php

session_start();

require_once("dbconnect.php");


//  verifica daca exista date transmise

if ($_POST['register_name'] != "" && $_POST['register_username'] != "" && $_POST['register_password'] != '') {


    // preia datele din formular

    $name = $_POST['register_name'];

    $username = $_POST['register_username'];

    $password = md5($_POST['register_password']);


    // formeaza si executa query-ul de inserare in baza de date

    $query = "INSERT INTO `users` (`Name`,`Username`,`Password`) VALUES ('".$name."','".$username."','".$password."')";

    $result = mysql_query($query) or die ( "Error : ". mysql_error() );


    // afiseaza un mesaj de succes

    if ($result) {

        echo "Inregistrarea a fost efectuata cu succes.<br>

            Click <a href='index.php'>aici</a> pentru a reveni la pagina de login";

    }

}

?>


//MD5 (Message Digest Algorithm 5) este o functie criptografica de tip hash unidirectional, care livreaza ca rezultat o valoare fixa ca lungime de 128 Biti. Valuarea calculata cu ajutorul functiei MD5 (pe scurt md5sum), este folosita insa pe scara larga drept suma de control, la verificarea integritatii fisierelor. 

//Functia md5() din PHP returneaza hash-ul ca un numar hexazecimal (in baza 16) de 32 caractere.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.