🔒 Closed Md5 registration in php

Status
Not open for further replies.

syml1nk

Journeyman
Creating Database Connection
save this as config.php

PHP:
 $database = new PDO ("mysql:host=localhost;dbname=db_name", 'root', 'user_pw');

Creating Registration Form
save this as index.php

PHP:
<div>
<form method="POST" action="register.php">
  <div class="form-group">
    <label>Email Address</label>
    <input type="email" name="email" class="form-control" placeholder="Email Address" required>
  </div>
  <div class="form-group">
    <label>Password</label>
    <input type="password" name="password" class="form-control" placeholder="Password" required>
  </div>
  <div class="form-group">
    <label>Re-type Password</label>
    <input type="password" name="re_password" class="form-control" placeholder="Re-type Password" required>
  </div>
  <button type="submit" name="btn_submit" class="btn btn-primary">Submit</button>
</form>
</div>

Inserting Data to Database
save this as register.php
PHP:
require_once ('config.php');

if (isset($_POST['btn_submit'])) {

$email = $_POST['email'];
$password = md5($_POST['password']);
$re_password = md5($_POST['re_password']);

if ($password != $re_password) {
    echo "<script>alert('Your Password does not match . . .'); window.location = 'index.php' </script>";
}    else

{
$database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$insert_query = "INSERT INTO tbl_user (email, password, re_password)
VALUES (?, ?, ?)";

$insert = $database->prepare($insert_query);
$insert->execute(array($email, $password, $re_password));

echo "<script>alert('Account successfully added!'); window.location='index.php'</script>";
}
}

Output
upload_2018-8-14_20-21-15.png
 
Di na po secure yung md5, di na safe gamitin yung mysql, gamit na po tayo ng latest na mysqli. si na po safe yan.
yung bagong php meron na sila built-in na pang encrypt ng password.
 
why still use md5 instead of AES? If push na push kaparin sa md5 lagyan mo lang ng salt or added patterns sa password.
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 5
    Replies
  • 723
    Views
  • 4
    Participants
Last reply from:
lfasmpao

Trending Topics

Online now

Members online
1,163
Guests online
9,435
Total visitors
10,598

Forum statistics

Threads
2,336,302
Posts
29,290,074
Members
1,130,611
Latest member
kdindot8
Back
Top