-
Notifications
You must be signed in to change notification settings - Fork 1
/
insert.php
50 lines (44 loc) · 1.56 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
<?php
$username =$_POST['username'];
$password =$_POST['Password'];
$gender =$_POST['gender'];
$email =$_POST['email'];
$phonecode =$_POST['phonecode'];
$phone =$_POST['phone'];
if(!empty($username) || !empty($password) || !empty($gender) || !empty($email) || !empty($phonecode) || !empty($phone) )
{
$host ="localhost";
$dbusername ="root";
$dbpassword ="";
$dbname ="youtube" ;
//create connection
$conn = new mysqli($host, $dbusername, $dbpassword, $dbname);
if(mysqli_connect_error()){
die('connect error('. mysqli_connect_error().')' .mysqli_connect_error());
} else{
$SELECT ="SELECT email From register Where email =? Limit 1";
$INSERT ="INSERT Into register (username, password, gender, email, phonecode, phone) values(?, ?, ?, ?, ?, ?)";
//Preaper statement
$stmt = $conn->preaper($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->preaper($INSERT);
$stmt->bind_param("ssssii", $username, $password, $gender, $email, $phonecode, $phone);
$stmt->execute();
echo "New record inserted sucessfully";
} else{
echo "someone already registerd using this email";
}
$stmt->close();
$conn->closes();
}
} else {
echo "All field are required";
die();
}
?>