0% found this document useful (0 votes)
15 views1 page

PHP

This PHP code handles user registration by inserting user data into a database table if the username is unique and passwords match, then starts a user session and redirects to the home page.

Uploaded by

Satria Pamungkas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

PHP

This PHP code handles user registration by inserting user data into a database table if the username is unique and passwords match, then starts a user session and redirects to the home page.

Uploaded by

Satria Pamungkas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

<?

php

include "config.php";

if ($_POST['register']) {

$name = $_POST['name'];

$user = $_POST['username'];

$age = $_POST['age'];

$pass = $_POST['password'];

$pass2 = $_POST['password2'];

if ($pass == $pass2) {

$check = mysqli_query($db,"select * from user where username='$user'");

$num = mysqli_num_rows($check);

$save = mysqli_fetch_array($check);

if ($num == 0) {

$insert = mysqli_query($db,"insert into user value(NULL, '$user', '$pass',


'$name', '$age')");

if ($insert) {

$QUSER = mysqli_query($db,"select * from user where username = '$user' &&


password='$pass' ");

$USER= mysqli_fetch_array($QUSER);

$_SESSION['user'] = $USER;

echo "<p>Welcome, your register as".$user;

header("location:home.php");

} else { }

You might also like