-
Notifications
You must be signed in to change notification settings - Fork 0
/
Userend.java
81 lines (66 loc) · 2.73 KB
/
Userend.java
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
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.*;
public class Userend {
static Scanner sc = new Scanner(System.in);
static String email;
static String password;
static long phoneno;
static String fullname;
static String address;
static void login()
{
Store storeobj = new Store();
CheckLogin check =new CheckLogin();
System.out.println("Enter your Email: ");
email = sc.nextLine();
System.out.println("Enter your password: ");
password = sc.nextLine();
boolean flag = check.validate(email, password);
if(flag == true) {
storeobj.shop();
}
else
{
System.out.println("You dont have a account, redirecting to creating process!");
Userend.signup();
}
}
static void signup()
{
System.out.println("Enter your Fullname: ");
fullname = sc.nextLine();
System.out.println("Enter your phone no: ");
phoneno = sc.nextLong();
System.out.println("Enter your Email: ");sc.nextLine();
email = sc.nextLine();
System.out.println("Enter your password: ");
password = sc.nextLine();
System.out.println("Enter your address: ");
address = sc.nextLine();
try{
Class.forName("org.mariadb.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mariadb://localhost:3306/Fruitables","root","");
PreparedStatement s1 = con.prepareStatement("insert into userdetails values(?,?,?,?,?)");
s1.setString(1, fullname);
s1.setLong(2, phoneno);
s1.setString(3, email);
s1.setString(4, password);
s1.setString(5, address);
s1.executeUpdate();
PreparedStatement s2 = con.prepareStatement("insert into userlogindetails values(?,?)");
s2.setString(1, email);
s2.setString(2, password);
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println("You have successfully created your account! ");
System.out.println();
System.out.println("Shop our fresh organic fruits and vegetables and stay healthy");
System.out.println("Happy Shopping!!");
Userend.login();
}
}