ARTICLE AD BOX
I own a jewellery company and I'm making a login system for my webshop. Here I'm using a register.php whereas I want to delay $_success and $_errors messages, and the code that is actually taking care of the form is.
So, basically what I want is register.php to display errors EVEN THOUGH the handling script is on the page that register.php is redirected to through form.
This is my register.php:
<?php include('db-connect.php'); ?> <?php ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); ?> <?php session_start(); ?> <!-- ... --> <BODY> <?php if ($_errors): ?> <div id="_errors"/> <?php foreach ($_errors as $e): ?> <?php echo htmlspecialchars($e); ?> <?php endforeach; ?> </div> <?php endif; ?> <?php if ($_success): ?> <div id="_success"/> <?php foreach ($_success as $s): ?> <?php echo htmlspecialchars($s); ?> <?php endforeach; ?> </div> <?php endif; ?> <FORM CLASS="_ELISESVINTAGE" METHOD="post" ACTION="login.php"> <LABEL>Användarnamn:</LABEL> <INPUT TYPE="text" NAME="_USER" REQUIRED AUTOCOMPLETE="off"> <LABEL>Lösenord:</LABEL> <INPUT TYPE="password" NAME="_PASS" REQUIRED AUTOCOMPLETE="on"> <INPUT TYPE="submit" NAME="_button" VALUE="submitQuery"> </FORM> </BODY> </HTML>I want to delay the error and success messages, The handling of the form comes on the page its directing to (login.php):
Here's login.php:
<?php if ([isset($_POST['_button'])]) if ([isset($_POST['_USER'], $_POST['_PASS'])]) { $_USER=$_POST['_USER']; $_PASS=$_POST['_PASS']; $_mikka=$pdo->prepare("INSERT INTO users (user,pass) VALUES (:user, :pass)"); $_mikka->bindParam(':user', $_USER); $_mikka->bindParam(':pass', password_hash($_PASS, PASSWORD_BCRYPT)); $_mikka->execute(); if ([$_mikka->rowCount() == 0]) { # rowCount() /* Countless errors */ /* Invented by Google */ } else { /* Try n cram stuff here */ } }