<?php
include 'connect.php';
session_start();
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pocta</title><link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@600&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="bootstrap-grid.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="shortcut icon" type="image/png" href="Photo/logo2.png">
</head>
<body>
<div class="form-div">
<form method="POST" action="register.php">
<div class="logo">
<img src="Photo/logo2.png">
</div>
<div class="title">
<a class="reg-link" href="index.php">Login</a> <span style="color:#2844ce">|</span> <a class="log-link" href="#">Register</a>
</div>
<div class="form">
<input placeholder="Name" type="text" name="fname">
<input placeholder="Surname" type="text" name="sname">
<input placeholder="Date of birth" type="text" name="birthd">
<input placeholder="Phone number" type="number" name="phonenumber">
<input placeholder="City" type="text" name="city">
<input placeholder="Gender" type="text" name="gender">
<input placeholder="Company" type="text" name="comp">
<input placeholder="Profession" type="text" name="profesion">
<input placeholder="Postmail" type="text" name="post">
<input placeholder="Email" type="email" name="email">
<input placeholder="Password" type="password" name="password">
<input placeholder="Confirm password" type="password" name="password2">
<article><a class="fog-link" href="#">Do you have account yet?</a></article>
<input name="submit" type="submit" class="submit-btn" value="Submit"></input>
<?php
if (!empty($_POST['submit'])) {
if (!empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) {
$sname = $_POST['sname'];
$fname = $_POST['fname'];
$email = $_POST['email'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$birthdate = $_POST['birthd'];
$phonenumber = $_POST['phonenumber'];
$city = $_POST['city'];
$gender = $_POST['gender'];
$comp = $_POST['comp'];
$prof = $_POST['profession'];
$post = $_POST['post'];
if ($password == $password2) {
if ($gender == 'male' || $gender == 'Male') {
$gender = '1';
}
if ($gender == 'female' || $gender == 'Female') {
$gender = '2';
}
$password = md5($_POST['password']);
$query = mysqli_query($conn, "INSERT INTO `users` (`fname`, `sname`, `email`, `password`, `birthdate`, `phonenumber`, `city`, `gender`, `company`, `profession, `postmail`) VALUES ( '" . mysqli_escape_string($conn,$fname) . "', '" . mysqli_escape_string($conn,$sname) . "', '" . mysqli_escape_string($conn,$email) . "', '" . mysqli_escape_string($password) . "', '" . mysqli_escape_string($conn,$birthdate) . "', '" . mysqli_escape_string($conn,$phonenumber) . "', '" . mysqli_escape_string($conn,$city) . "', '" . mysqli_escape_string($conn,$gender) . "', '" . mysqli_escape_string($conn, $comp) . "', '" . mysqli_escape_string($conn,$prof) . "', '" . mysqli_escape_string($conn,$post) . " ') ");
if ($query) {
echo '<article style="color: green">Success!</article>';
}
}else {
echo '<article style="color: red">Passwords don\'t match!</article>';
}
}
}
?>
</div>
</form>
</div>
</body>
</html>