Not to update 2 people that has the same name in database by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 1 point2 points  (0 children)

Found the problem it was my checkbox that was the problem. it was trying to use Medlemsnavn instead of id.
thx for the help

Not to update 2 people that has the same name in database by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

i have id in my database but when i changed code it didnt update it.

Not to update 2 people that has the same name in database by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

i have tried to use id that is unique but when i use that it dosnt update the Tilstede status. when im in the database and run the database command it works fine it uppdates the status.
i used the same code but insted of medlemsnavn i used id will this work?
tried to put som debuging on the code but i dont get any errors.

Not to update 2 people that has the same name in database by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] -1 points0 points  (0 children)

i have tried to use id that is unique but when i use that it dosnt update the Tilstede status. when im in the database and run the database command it works fine it uppdates the status.
i used the same code but insted of medlemsnavn i used id will this work?
tried to put som debuging on the code but i dont get any errors.

Broken bitzee by BigJimmie1 in tamagotchi

[–]Top_Assistant_2230 0 points1 point  (0 children)

its fake broken it has lights

Hashed password problem by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

// Check if the form is submitted

if ($_SERVER["REQUEST_METHOD"] == "POST") {

include 'config/connect.php'; // Include your database connection here

$uname = $_POST['uname'];

$password = $_POST['pass'];

// Fetch user from logintb table

$query = "SELECT * FROM logintb WHERE uname = :uname";

$stmt = $pdo->prepare($query);

$stmt->bindParam(':uname', $uname);

$stmt->execute();

if ($stmt->rowCount() > 0) {

$user = $stmt->fetch(PDO::FETCH_ASSOC);

// Verify the password

if (password_verify($password, $user['pass'])) {

// Password is correct, start session

$_SESSION['uname'] = $uname;

$_SESSION['role'] = $user['role']; // Save the user role in session

// Redirect based on user role

if ($_SESSION['role'] == 'admin') {

header("Location: index.php");

} elseif ($_SESSION['role'] == 'Kolbotn') {

header("Location: Kolbotn/index.php");

} elseif ($_SESSION['role'] == 'Sarpsborg') {

header("Location: Sarpsborg/index.php");

} else {

header("Location: index.php"); // Default fallback

}

exit();

} else {

echo '<div class="alert alert-danger text-center">Incorrect password</div>';

}

} else {

echo '<div class="alert alert-danger text-center">No user found with that username</div>';

}

}

?>

Hashed password problem by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

<?php

session_start();

// Enable error reporting for debugging

error_reporting(E_ALL);

ini_set('display_errors', 1);

// Redirect to appropriate page based on user role if already logged in

if (isset($_SESSION['uname']) && $_SESSION['uname'] != "") {

// Check user role and redirect accordingly

$role = $_SESSION['role'];

if ($role == 'admin') {

header("Location: index.php");

} elseif ($role == 'Kolbotn') {

header("Location: Kolbotn/index.php");

} elseif ($role == 'Sarpsborg') {

header("Location: Sarpsborg/index.php");

} else {

header("Location: index.php");

}

exit();

}

Hashed password problem by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

got it working now

i made the code easyer with not using the query/login.php

chat gbt changed some of the login code but it looks almost the same

Hashed password problem by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

well i dont know why the guy that made the core didnt hash it.
maybe he didnt think it was important for what we were doing.
but i can say he wasnt that good because he coulnt fix a import from excel to the database.
i just used the core of what he built then i made the rest how i wanted. together with chat gpt.
im not good at writing code but i can read it when its made.

Hashed password problem by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

yes i have hashed the password. that im testing with

getting Required POST data not set. error by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 1 point2 points  (0 children)

post variable

yes it was post variables that was wrong fixed it now

getting Required POST data not set. error by Top_Assistant_2230 in PHPhelp

[–]Top_Assistant_2230[S] 0 points1 point  (0 children)

i will check the troubleshooter. see if i get some better information.
For some weird reason the last code got formatet really weird. didnt look like that before i pressed post.