?
Solved

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

Posted on 2011-05-05
7
Medium Priority
?
238 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:MILIND_JOG
7 Comments
 
LVL 6

Expert Comment

by:bartvd
ID: 35697436
Could you give your code please?
0
 

Author Comment

by:MILIND_JOG
ID: 35697450
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
 

Author Comment

by:MILIND_JOG
ID: 35697465
I do not want to create the href. I want directly to go back to sign.php if validaty fails.

Regards

Milind
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 1000 total points
ID: 35697487
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
 

Author Comment

by:MILIND_JOG
ID: 35697495
OK.

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

Regards
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35697738
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
 

Author Closing Comment

by:MILIND_JOG
ID: 35885622
Hi,
Thanks for your support. It is working fine.

Regards
Milind
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question