I have only slightly modified this code from the tutorial and code at the following page.
https://devdojo.com/episode/create-a-php-login-script
The form loads fine but I get an error on execution. If I comment out the if statement containing the execute function the code doesn’t throw errors. I use Yahoo webhosting (not the best) and the newest php version they support is 5.3.6. Is there something about using PDO that wouldn’t be supported by this version? Aside from the fact that I am not using password_hash in this code?
<?php
session_start();
require 'config.php';
$msg = '';
if(!empty($_POST['userEmail']) && !empty($_POST['userPass'])):
$sql = "INSERT INTO users (userEmail, userPass) VALUES (:userEmail, :userPass)";
$db = getDB();
$stmt = $db->prepare($sql);
$stmt->bindParam(':userEmail', $userEmail);
$stmt->bindParam(':userPass', $userPass);
$userEmail = $_POST['userEmail'];
$userPass = $_POST['userPass'];
echo $sql;
if( $stmt->execute() ):
$msg = 'Successfully created new user';
else:
$msg = 'There was an error creating the new account';
endif;
endif;
?>