Solved

PHP equivalent of ColdFusion <CFABORT>

Posted on 2003-11-10
3
2,015 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Paging Using PHP 7 35
Return data with AJAX, JQUERY and PHP 13 38
Change password through link 1 13
Datepicker in PHP 9 21
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The viewer will learn how to count occurrences of each item in an array.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now