-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreg_update.php
28 lines (25 loc) · 1.11 KB
/
reg_update.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
<?php
require('db_connect.php');
// Assigning POST values to variables.
$username = $_POST['uName'];
$password = $_POST['pWord'];
$firstname = $_POST['fName'];
$lastname = $_POST['lName'];
$gender = $_POST['gender'];
$telephone = $_POST['tlPhone'];
$address = $_POST['address'];
$email = $_POST['email'];
// Calculates the number of registered accounts.
$max_id = pg_fetch_all(pg_query($db_connection, "SELECT MAX(user_id) FROM account"))[0]['max'];
$result = (string)((int)$max_id+1);
// Registers the newly created account into DB.
$query = "INSERT INTO account(user_id, user_name, user_passwd, user_fname, user_lname, user_gender, user_tel, user_address, user_email) VALUES ('$result', '$username', '$password', '$firstname', '$lastname', '$gender', '$telephone', '$address', '$email')";
// Checks if registration is successful.
if (pg_query($db_connection, $query)){
// Displays message and redirects.
echo "<script type='text/javascript'>alert('Successful')</script>";
echo "<script> window.location.href = 'Login_Page.php' </script>";
} else{
echo "ERROR: Could not able to execute $sql. " . pg_error($db_connection);
}
?>