How to go back to calling PHP if faied some validation test in called PHP script automatically

Hi,

I have written a PHP script asking for 'USER' and 'PASSWORD'. I am calling a validation PHP script after input. If USER and PASSWORD is not valid, I want to go back to calling PHP with Error Message.

Please help

Regards

Milind
MILIND_JOGAsked:
Who is Participating?
 
Lukasz ChmielewskiConnect With a Mentor Commented:
So you need to do this:

if ($a === "0")
{
   header("Location: sign.php");
//    echo '<br /><a href="sign.php">page 2</a>';
}  

Open in new window

0
 
bartvdCommented:
Could you give your code please?
0
 
MILIND_JOGAuthor Commented:
Thanks for response

<?PHP
session_start();
$conn = oci_connect('apps', 'avtectest','//XXX.XX.XX.XX:XXXX/TEST') or die('fail: ');
$usr = $_POST['login'];
$pass = $_POST['password'];
//echo "$pass";
$query = "SELECT count(*) AS MM  FROM AVTEC_WEB_USERS WHERE USER_NAME = '$usr' and user_password = '$pass'";

$sth = OCI_parse($conn, $query);
if (!$sth) {

$e = oci_error($conn);
echo htmlentities($e['message']);
die;

}

$results = oci_execute($sth, OCI_DEFAULT);
$s = oci_fetch($sth);
$a = oci_result($sth,'MM');

//echo $a;

if ($a === "0")
{
    echo '<br /><a href="sign.php">page 2</a>';

}  

oci_close();
?>

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
MILIND_JOGAuthor Commented:
I do not want to create the href. I want directly to go back to sign.php if validaty fails.

Regards

Milind
0
 
MILIND_JOGAuthor Commented:
OK.

Let me try.
I will come back to you in 2 Mnts.

Regards
0
 
Ray PaseurCommented:
Please take a moment to read this article.  It teaches the design pattens you want to put into practice.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html
0
 
MILIND_JOGAuthor Commented:
Hi,
Thanks for your support. It is working fine.

Regards
Milind
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.