-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_profile2.php
95 lines (80 loc) · 3.18 KB
/
create_profile2.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
require 'dbconfig/config.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>SignUp</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body style="background-color:#7f8c8d">
<div id = "main-wrapper">
<center>
<h2>SignUp Form</h2>
<img src = "Images/loginImg.png" width="100px"/>
</center>
<form class="myform" action="signup.php" method="post">
<label><b>Name</b></label>
<input name="firstname" type="text" class="inputvalues" placeholder="Type your first name" width = "50%" required/><br>
<input name="lastname" type="text" class="inputvalues" placeholder="Type your last name" width = "50%" required/><br><br>
<label><b>Address</b></label>
<input name="addressNo" type="text" class="inputvalues" placeholder="Type Address Number" width = "50%" required/><br>
<input name="addressStreet" type="text" class="inputvalues" placeholder="Type Street" width = "50%" required/><br>
<input name="addressCity" type="text" class="inputvalues" placeholder="Type City" width = "50%" required/><br><br>
<label><b>Contact Number</b></label>
<input name="contactno" type="number" class="inputvalues" placeholder="Type your contact number" required/><br><br>
<label><b>Username</b></label>
<input name="username" type="text" class="inputvalues" placeholder="Type your username" required/><br>
<label><b>Password</b></label>
<input name="password" type="password" class="inputvalues" placeholder="Your password" required/><br>
<label><b>Confirm Password</b></label>
<input name="cpassword" type="password" class="inputvalues" placeholder="Confirm password" required/><br>
<input name="submit_btn" type="submit" id="signup2_btn" value="Sign Up"/><br>
<a href = "index.php"><input type="button" id="back_btn" value="Back"/></a>
</form>
<?php
if(isset($_POST['submit_btn']))
{
//echo '<script type = "text/javascript">alert("dsa")</script>';
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$addressNo = $_POST['addressNo'];
$addressStreet = $_POST['addressStreet'];
$addressCity = $_POST['addressCity'];
$contactno = $_POST['contactno'];
$type = "Farmer";
$username = $_POST['username'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
if($password==$cpassword)
{
$query = "SELECT * FROM login WHERE username='$username'";
$query_run = mysqli_query($con,$query);
if(mysqli_num_rows($query_run)>0)
{
echo '<script type = "text/javascript">alert("User already exists.... Try another username")</script>';
}
else
{
$query = "INSERT INTO login VALUES('$username','$firstname','$lastname','$addressNo','$addressStreet','$addressCity','$password','$contactno','$type')";
$query_run = mysqli_query($con,$query);
if($query_run)
{
header("location:agrariancreatepro.php");
echo '<script type = "text/javascript">alert("User Registered.")</script>';
}
else
{
echo '<script type = "text/javascript">alert("Error!!!")</script>';
}
}
}
else
{
echo '<script type = "text/javascript">alert("Password and Confirm Password does not match.")</script>';
}
}
?>
</div>
</body>
</html>