Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Første error:
- "Parse error: syntax error, unexpected '$dbServername' (T_VARIABLE) in /var/www/groupu6.dk/Test/includes/login.inc.php on line 9"
- Tilhørende script:
- <?php
- session_start()
- //if (isset($_POST['submit'])) {
- //include_once 'dbh.inc.php';
- $dbServername = "mysql66.unoeuro.com";
- $dbUsername = "groupu6_dk";
- $dbPassWord = "Jimmi2908";
- $dbname = "groupu6_dk_db";
- $conn = mysqli_connect($dbServername,$dbUsername,$dbPassWord,$dbname);
- $uid = mysqli_real_escape_string($conn,$_POST['uid']);
- $pwd = mysqli_real_escape_string($conn,$_POST['pwd']);
- //Error handlers
- //Check if inputs are empty
- if(empty($uid)||empty($pwd)) {
- header("Location: ../index.php?login=empty");
- exit();
- }else {
- $sql = "SELECT * FROM workers WHERE worker_uid='$uid'";
- $result = mysqli_query($conn,$sql);
- $resultCheck = mysqli_num_rows($result);
- if ($resultCheck < 1) {
- header("Location: ../index.php?login=error");
- exit();
- } else {
- if($row = mysqli_fetch_assoc($result)){
- //De-hashing the password
- $hashedPwdCheck = password_verify($pwd, $row['workers_pwd']);
- if ($hashedPwdCheck == false) {
- header("Location: ../index.php?login=error");
- exit();
- } elseif ($hashedPwdCheck == true) {
- //log in the user here
- $_SESSION['u_id'] = $row['workers_id'];
- $_SESSION['u_nare'] = $row['workers_name'];
- $_SESSION['u_email'] = $row['workers_email'];
- $_SESSION['u_uid'] = $row['workers_uid'];
- header("Location: ../index.php?login=success");
- exit();
- }
- }
- }
- }
- }else {
- header("Location: ../index.php?login=error");
- exit();
- }
- Anden Error:
- "Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /var/www/groupu6.dk/Test/includes/signup.inc.php on line 29
- Warning: Cannot modify header information - headers already sent by (output started at /var/www/groupu6.dk/Test/includes/signup.inc.php:29) in /var/www/groupu6.dk/Test/includes/signup.inc.php on line 42"
- Tilhørende script:
- <?php
- if (isset($_POST['submit'])) {
- include_once 'dbh.inc.php';
- $first = mysqli_real_escape_string($conn,$_POST['name']);
- $email = mysqli_real_escape_string($conn,$_POST['email']);
- $uid = mysqli_real_escape_string($conn,$_POST['uid']);
- $pwd = mysqli_real_escape_string($conn,$_POST['pwd']);
- //Error handlers
- //Check for empty fieldset
- if (empty($first)||empty($email)||empty($uid)||empty($pwd)) {
- header("Location: ../signup.php?signup=empty");
- exit();
- } else{
- //Check if input is valid
- if (!preg_match("/^[a-åA-Å]*$/",$first) || !preg_match("/^[a-zA-Z]*$/",$uid)) {
- header("Location: ../signup.php?signup=invalid=characters");
- exit();
- } else{
- //Check If email is valid
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- header("Location: ../signup.php?signup=invalid=email");
- exit();
- } else {
- $sql = "SELCELT * FROM workers WHERE worker_uid='$uid'";
- $result = mysqli_query($conn,$sql);
- $resultCheck = mysqli_num_rows($result);
- }
- if ($resultCheck > 0) {
- header("Location: ../signup.php?signup=username=taken");
- exit();
- } else {
- //Hashing the password
- $hashedPwd = password_hash($pwd,PASSWORD_DEFAULT);
- //insert the user to the databbase
- $sql = "INSERT INTO 'workers' (workers_name,worker_email,workers_uid,worker_pwd) VALUES ('$name','$email
- ','$uid','$hashedPwd');";
- mysqli_query($conn,$sql);
- header("Location: ../index.php?signup=user=sucess");
- exit();
- }
- }
- }
- } else{
- header("Location: ../signup.php");
- exit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement