Solved

PHP equivalent of ColdFusion <CFABORT>

Posted on 2003-11-10
3
2,052 Views
Last Modified: 2013-12-16
I'm rewriting an application to PHP from ColdFusion.

There's a handy ColdFusion tag called <CFABORT>.  It basically stops execution, such as may be appropriate after someone has entered a bad password.  Without this tag, one has to use more if/else logic and it can get tedious.  

For example, with CFABORT, you can code:

<CFIF PasswordStatus IS "Bad">
  BAD PASSWORD! GO AWAY!
  <CFABORT>
</CFIF>
Hi!  
Welcome to our site, authorized user
etc.

Without CFABORT, you'd have to code:

For example, with CFABORT, you can code:

<CFIF PasswordStatus IS "Bad">
  BAD PASSWORD! GO AWAY!
  <CFABORT>
<CFELSE>
  Hi!  
  Welcome to our site, authorized user
  etc.
</CFIF>

Thanks.
0
Comment
Question by:volvopilot
3 Comments
 
LVL 1

Accepted Solution

by:
rstorey2079 earned 125 total points
ID: 9725949
exit();

you can optionally specify an error code as an argument if you wish.

http://us2.php.net/manual/en/function.exit.php

0
 
LVL 7

Assisted Solution

by:minnirok
minnirok earned 125 total points
ID: 9726185
Be careful if you use the exit(); command ( also known as die(); )...   Once the server executes either this function it will stop processing your script.  This will likely cause problems if you're displaying a graphical user interface, since the html tags you'd meant to output after the error occured will not be sent to the client machine.

You should structure your php page with locical IF statements within PHP. So:

<?php
if( $passwordStatus == "Bad" ) {  //return error msg for bad password
   echo "<b>Bad Password! Go Away!</b><br />\n";
} else { // password is good, continue
   echo "Hi!<br />\n" .
           "Welcome to our site, authorized user<br />\n";
} // end if else statement
?>

PHP has built in database connectivity funtions for oracle, mysql, sql server ECT so you'll first need to familiarize yourself with the relevant functions for whatever database you're using.  mySQL is overwhelmingly the most widely used with PHP...  The PHP and Databases forum is better suited for any further elaboration.
0
 

Author Comment

by:volvopilot
ID: 9727003
Thank you, both.

I doubled the points and so I gave you each 125.

Thanks again.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The viewer will learn how to count occurrences of each item in an array.

809 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