Solved

PHP equivalent of ColdFusion <CFABORT>

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

730 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