SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php session_start(); | |
| 2 | ||
| 3 | $emaillogin = ''; | |
| 4 | $action = $_GET[action]; | |
| 5 | ||
| 6 | //code for adding new user | |
| 7 | $lnamenew = $_POST['Lname']; | |
| 8 | $fnamenew = $_POST['Fname']; | |
| 9 | $emailnew = $_POST['Email']; | |
| 10 | $passnew = $_POST['Pass']; | |
| 11 | if($fnamenew != "") | |
| 12 | {
| |
| 13 | $query = "INSERT INTO users VALUES (seq_ID.nextval,'$fnamenew','$lnamenew','','','','','','','','$emailnew','$passnew')"; //case insensitive | |
| 14 | ||
| 15 | ||
| 16 | /* Set oracle user login and password info */ | |
| 17 | $dbuser = "lmacfarl"; /* your deakin login */ | |
| 18 | $dbpass = "newpassword"; /* your deakin password */ | |
| 19 | $db = "SSID"; | |
| 20 | $connect = oci_connect($dbuser, $dbpass, $db); | |
| 21 | if (!$connect) {
| |
| 22 | echo "An error occurred connecting to the database"; | |
| 23 | exit; | |
| 24 | } | |
| 25 | /* check the sql statement for errors and if errors report them */ | |
| 26 | $stmt = oci_parse($connect, $query); | |
| 27 | //echo "SQL: $query<br>"; | |
| 28 | if(!$stmt) {
| |
| 29 | echo "An error occurred in parsing the sql string.\n"; | |
| 30 | exit; | |
| 31 | } | |
| 32 | oci_execute($stmt); | |
| 33 | $_SESSION["loggedin"] = "true"; | |
| 34 | $_SESSION["fname"] = $fnamenew; | |
| 35 | $_SESSION["lname"] = $fnamenew; | |
| 36 | $_SESSION["email"] = $fnamenew; | |
| 37 | oci_close($connect); | |
| 38 | } | |
| 39 | ||
| 40 | //code for logging in | |
| 41 | ||
| 42 | $emaillogin = $_POST["email"]; | |
| 43 | $password = $_POST["password"]; | |
| 44 | ||
| 45 | if($emaillogin != "") | |
| 46 | {
| |
| 47 | $query = "SELECT * FROM users WHERE EMAIL LIKE '$emaillogin' AND PASSWORD LIKE '$password'"; //case insensitive | |
| 48 | //echo("$query");
| |
| 49 | ||
| 50 | /* Set oracle user login and password info */ | |
| 51 | $dbuser = "lmacfarl"; /* your deakin login */ | |
| 52 | $dbpass = "newpassword"; /* your deakin password */ | |
| 53 | $db = "SSID"; | |
| 54 | $connect = oci_connect($dbuser, $dbpass, $db); | |
| 55 | if (!$connect) {
| |
| 56 | echo "An error occurred connecting to the database"; | |
| 57 | exit; | |
| 58 | } | |
| 59 | /* check the sql statement for errors and if errors report them */ | |
| 60 | $stmt = oci_parse($connect, $query); | |
| 61 | //echo "SQL: $query<br>"; | |
| 62 | if(!$stmt) {
| |
| 63 | echo "An error occurred in parsing the sql string.\n"; | |
| 64 | exit; | |
| 65 | } | |
| 66 | oci_execute($stmt); | |
| 67 | ||
| 68 | while (oci_fetch_array($stmt)) {
| |
| 69 | ||
| 70 | ||
| 71 | $_SESSION["loggedin"] = "true"; | |
| 72 | $_SESSION["fname"] = oci_result($stmt,"FIRSTNAME"); | |
| 73 | $_SESSION["lname"] = oci_result($stmt,"LASTNAME"); | |
| 74 | $_SESSION["email"] = oci_result($stmt,"EMAIL"); | |
| 75 | ||
| 76 | oci_close($connect); | |
| 77 | } | |
| 78 | } | |
| 79 | if($action == 'logout') | |
| 80 | {
| |
| 81 | $_SESSION["loggedin"] = "false"; | |
| 82 | $_SESSION["fname"] = ''; | |
| 83 | $_SESSION["lname"] = ''; | |
| 84 | $_SESSION["email"] = ''; | |
| 85 | } | |
| 86 | ||
| 87 | ?> |