-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignup.php
78 lines (58 loc) · 2.47 KB
/
signup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
//require 'Connections/database.php';
require_once "clases/conexion.php";
$message = '';
try {
if (!empty($_POST['user']) && !empty($_POST['password']) && !empty($_POST['email']) && !empty($_POST['confirm_password']) ) {
if($_POST['confirm_password'] == $_POST['password'] ) {
$obj= new conectar();
$conexion=$obj->conexion();
$user = mysqli_real_escape_string($conexion,$_POST['user']);
$pass = password_hash($_POST['password'], PASSWORD_BCRYPT);
$email = mysqli_real_escape_string($conexion,$_POST['email']);
if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email)){
// Return Error - Invalid Email
$message = 'The email you have entered is invalid, please try again.';
}else{
// Return Success - Valid Email
$hash = md5( rand(0,1000) ); // Generate random 32 character hash and assign it to a local variable.
$sql = "INSERT INTO user (user, email, password, token) VALUES ('$user','$email','$pass','$hash')";
if ($result=mysqli_query($conexion,$sql)) {
require 'procesos/sendmail.php';
} else {
$message = 'Sorry there must have been an issue creating your account';
}
}
} else {
$message = 'Las contraseñas no coinciden';
}
}
} catch (Exception $e) {
die('Connection Failed: ' . $e->getMessage());
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>BulkGuasapp</title>
<link rel="shortcut icon" href="static/img/bulkguasapp-logo.ico" />
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="librerias/tinchoram/css/login.css">
</head>
<body>
<?php require 'partials/initheader.php' ?>
<?php if(!empty($message)): ?>
<p> <?= $message ?></p>
<?php endif; ?>
<h1>SignUp</h1>
<span>or <a href="index.php">Login</a></span>
<form action="signup.php" method="POST">
<input name="user" type="text" placeholder="Enter your user">
<input name="email" type="text" placeholder="Enter your email">
<input name="password" type="password" placeholder="Enter your Password">
<input name="confirm_password" type="password" placeholder="Confirm Password">
<input type="submit" value="Submit">
</form>
</body>
</html>