-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinsert.php
67 lines (66 loc) · 2.1 KB
/
insert.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
<?php
session_start();
header('location:Homepage1.php');
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$phoneCode = $_POST['phoneCode'];
$phone = $_POST['phone'];
$gender = $_POST['gender'];
if(!empty($username) || !empty($password) || !empty($gender) || !empty($email) || !empty($phoneCode) || !empty($phone) || !empty($password2))
{
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "project";
$conn =new mysqli($host, $dbUsername, $dbPassword, $dbname);
if(mysqli_connect_error())
{
die('Connect Error('.mysqli_connect_errno().')'.mysqli_connect_error());
}
else
{
if($password == $password2)
{
$SELECT = "SELECT email From register Where email = ? Limit 1";
$INSERT = "INSERT Into register (username, password, gender, email, phoneCode, phone) values (?,?,?,?,?,?)";
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s",$email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum=$stmt->num_rows;
if($rnum==0)
{
$stmt->close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("ssssii",$username, $password, $gender, $email, $phoneCode, $phone);
$stmt->execute();
echo '<script type="text/javascript"> window.onload= function() { alert("New record entered successfully");}</script>';
//echo '<p style="text-decoration:none; float: right; padding-right: 20px; font-size: 24px; color: #E2472F;">Hi,'.$username.'</p>';
//include("Homepage1.html");
$_SESSION['username'] = $username;
include('location:Homepage1.php');
}
else
{
echo '<script type="text/javascript"> window.onload= function() { alert("Already registered Email Address");}</script>';
include("register.html");
}
$stmt->close();
$conn->close();
}
else
{
echo '<script type="text/javascript"> window.onload= function() { alert("Both Passwords didnt match");}</script>';
include("register.html");
}
}
}
else
{
echo "All field are required";
die();
}
?>