r/PHPhelp • u/recluzeMe • Dec 16 '25
Solved header() function in php
<?php
if(isset($_POST["submitted"]))
{
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$email = $_POST["email"];
$passd = $_POST["passd"];
$confirmPassword = $_POST["Cpassd"];
$conn = new PDO("mysql:hostname=localhost;dbname=signlogin;","root","");
$sqlQuery = "INSERT INTO signup(firstname,lastname,email,PASSWORD,confirmPassword) values('$firstname','$lastname','$email','$passd','$confirmPassword')";
$stmt = $conn->prepare($sqlQuery);
$stmt->execute();
header('Location: http://localhost/phpForm/login.php');
exit();
}
page doesn't redirect to login page hence file login.php is in same folder
http://localhost/login.php
instead of:
http://localhost/phpForm/login.php
?>
View all comments
Show parent comment
6
u/allen_jb Dec 16 '25
For hashing passwords, use PHP's password functions: https://www.php.net/password
You want to use
password_hash()to create the hash, thenpassword_verify()during login to verify the entered password matches the hash. You should also implementpassword_needs_rehash()during login to check if the hash needs to be upgraded.