source: Sign Up.php@ f9c482b

Last change on this file since f9c482b was f9c482b, checked in by Vlado 222039 <vlado.popovski@…>, 6 days ago

Upload new project files

  • Property mode set to 100644
File size: 4.5 KB
Line 
1<?php
2
3 require __DIR__ . "/vendor/autoload.php";
4
5 $client = new Google\Client;
6
7 $client->setClientId("");
8 $client->setClientSecret("");
9 $client->setRedirectUri('http://localhost:8000/redirect.php');
10
11 $client->addScope("email");
12 $client->addScope("profile");
13
14 $url = $client->createAuthUrl();
15
16?>
17
18<!DOCTYPE html>
19<html lang="en">
20<head>
21 <meta charset="UTF-8">
22 <meta name="viewport" content="width=device-width, initial-scale=1.0">
23 <title>Innova</title>
24 <link rel="stylesheet" href="CSS/TOS.css">
25 <link rel="stylesheet" href="CSS/Entry.css">
26</head>
27<body>
28 <form method="POST" action="./validateSignUp.php">
29 <h1>
30 Направете корисничка сметка!
31 </h1>
32 <div class="inputfield">
33 <input type="text" name="email" id="EMAIL_ID" required>
34 <span class="labeline" id="emailLabel">Email address</span>
35 </div>
36 <div class="inputfield">
37 <input type="text" name="username" id="USERNAME_ID" required>
38 <span class="labeline" id="userLabel">Username</span>
39 </div>
40 <div class="inputfield">
41 <input type="password" name="password" id="PASSWORD_ID" required>
42 <span class="labeline" id="passwordLabel">Password</span>
43 </div>
44 <div>
45 <button id="continue" type="submit">Продолжете</button>
46 <p>Имате веќе корисничка сметка? <a href="./Log In.php">Sign in</a></p>
47 </div>
48 <div class="oauth-container">
49 <a href="<?= $url ?>">Google Sign Up</a>
50 </div>
51 </form>
52
53 <div class="TOSContainer">
54 <h5><a href="./Information/">Контакт</a></h5>
55 <h5>|</h5>
56 <h5><a href="./Information/">За нас</a></h5>
57 <h5>|</h5>
58 <h5><a href="./Information/">Политика на приватност</a></h5>
59 </div>
60
61
62 <?php
63
64function GetEmail()
65{
66 if(!empty($_GET['email']))
67 {
68 $email = "\"".$_GET['email']."\"";
69
70 echo
71 "
72 <script>
73 var email = {$email};
74 document.getElementById(\"EMAIL_ID\").value=email;
75 </script>
76 ";
77 }
78}
79
80function GetUsername()
81{
82 if(!empty($_GET['username']))
83 {
84 $username = "\"".$_GET['username']."\"";
85
86 echo
87 "
88 <script>
89 var username = {$username};
90 document.getElementById(\"USERNAME_ID\").value=username;
91 </script>
92 ";
93 }
94}
95
96if(empty($_GET['error']))
97 exit();
98
99$error = $_GET["error"];
100
101switch($error)
102{
103 case 'INVALID_EMAIL':
104 echo '
105 <script>
106 document.getElementById("EMAIL_ID").style.border="1px solid red";
107 document.getElementById("EMAIL_ID").placeholder="Enter your Email Address";
108 document.getElementById("emailLabel").style.display = "none";
109 </script>
110 ';
111 break;
112 case 'INVALID_USERNAME':
113 echo '
114 <script>
115 document.getElementById("USERNAME_ID").style.border="1px solid red";
116 document.getElementById("USERNAME_ID").placeholder="Enter your username";
117 document.getElementById("userLabel").style.display = "none";
118 </script>
119 ';
120 GetEmail();
121 break;
122 case 'INVALID_PASSWORD':
123 echo '
124 <script>
125 document.getElementById("PASSWORD_ID").style.border="1px solid red";
126 document.getElementById("PASSWORD_ID").placeholder="Enter your password";
127 document.getElementById("passwordLabel").style.display = "none";
128 </script>
129 ';
130 GetEmail();
131 GetUsername();
132 break;
133 case 'USERNAME_TAKEN':
134 echo '
135 <script>
136 document.getElementById("USERNAME_ID").style.borderColor = "red";
137 document.getElementById("userLabel").style.display = "none";
138 document.getElementById("USERNAME_ID").placeholder="Username is already taken!";
139 </script>
140 ';
141
142 GetEmail();
143 break;
144 case 'EMAIL_TAKEN':
145 echo '
146 <script>
147 document.getElementById("EMAIL_ID").style.borderColor = "red";
148 document.getElementById("emailLabel").style.display = "none";
149 document.getElementById("EMAIL_ID").placeholder="Email address is already used!";
150 </script>
151 ';
152 GetUsername();
153 break;
154 default:
155 break;
156}
157?>
158
159</body>
160</html>
Note: See TracBrowser for help on using the repository browser.