CodingCF -> PHP

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  andy  
 To:  ALL
30894.1 
Trying to port a simple CF script to PHP and just wanted to double-check:

newsletterthanks.cf:

coldfusion code:
<CFPARAM name="URL.response" default="">
<CFPARAM name="URL.emailaddress" default="">

<!--- we should have got back URL.emailaddress (the email address) and URL.response
	URL.response will be one of:
		addedSuccess = Email successfully added to database
		addedSuccessAndEmailed = Email successfully added to database, autoresponse emailed to user.
		existsNotAdded = Email is already in the database, no action taken.
		removeSuccess = Email successfully removed from database
		removeSuccessAndEmailed = Email successfully removed from database, autoresponse emailed to user.
		removeFail = Email not found in the list, no action taken.
--->

<CFOUTPUT>

<CFIF URL.response EQ "addedSuccess" or URL.response EQ "addedSuccessAndEmailed">
<p><strong>Thankyou for subscribing to our newsletter!</strong></p>
<p>
You subscribed using the address: <CFIF isDefined("URL.emailaddress")>#URL.emailaddress#<CFELSE>[not returned]</CFIF>
</p>

<CFELSEIF URL.response EQ "existsNotAdded">
<p><strong>You are already subscribed to our newsletter!</strong></p>
<p>
You are already subscribed using the address: <CFIF isDefined("URL.emailaddress")>#URL.emailaddress#<CFELSE>[not returned]</CFIF>. No action has been taken.
</p>

<CFELSEIF URL.response EQ "removeSuccess" or URL.response EQ "removeSuccessAndEmailed">
<p><strong>You have been unsubscribed from our newsletter!</strong></p>
<p>
Your address<CFIF isDefined("URL.emailaddress")>, #URL.emailaddress#</CFIF> has been removed from our list.
</p>

<CFELSEIF URL.response EQ "removeFail">
<p><strong>We don't know you!</strong></p>
<p>
Your address<CFIF isDefined("URL.emailaddress")>, #URL.emailaddress#</CFIF> does not appear on our list. No action has been taken.
</p>

<CFELSE>
<p><strong>Unknown response - this shouldn't ever happen</strong></p>

</CFIF>

<p>
DEBUG: The list server said: <CFIF isDefined("URL.response")>#URL.response#<CFELSE>[not returned]</CFIF>
</p>

</CFOUTPUT>


newslettererror.cf:

coldfusion code:
<CFPARAM name="URL.error" default="">
<CFPARAM name="URL.emailaddress" default="">

<!--- we should get URL.error and URL.emailaddress 
	URL.error should be one of:
	err1 = *NOT ACTIVE* - script accessed with incorrect method (i.e called directly instead of POST action)
	err2 = missing/blank List ID
	err3 = non-valid List ID
	err4 = missing/blank email address
	err5 = non-valid email address (per email validation rules defined)
	err6 = subscriber limit reached
	err7 = invalid request type
	err8 = no response URL
--->

<p><strong>There was an error subscribing you to our newsletter!</strong></p>
<CFOUTPUT>
<p>
Your attempted to subscribe <CFIF isDefined("URL.emailaddress")>using the address #URL.emailaddress#</CFIF> unfortunately failed.
</p>

<p>
Debug: The list server gave this error code: <CFIF isDefined("URL.error")>#URL.error#<CFELSE>[not returned]</CFIF>
</p>
</CFOUTPUT>


Those URL.etc variables are just equivalent to $_POST['etc'] right? And everything else is just a standard if (..) { } else if (..) { } type structure, yep?
0/0
 Reply   Quote More 

 From:  -Daz-  
 To:  andy     
30894.2 In reply to 30894.1 
For a second there I thought Peter had realised the error of his ways.

From some publishing journal I read recently: "If you can't properly credit the source of a quote, then you should refrain from using it at all."
0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  -Daz-     
30894.3 In reply to 30894.2 
No such luck. I was actually expecting your reply to be Peter asking why he wasn't just using CF.

Antoine
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  andy     
30894.4 In reply to 30894.1 

The Url scope is basically query string stuff, which is $_GET['...'].
$_POST['...'] is Form scope.

 

And yes, you could use standard if / else if, but it would be so much better as a switch/case statement for the main one, and without the other IsDefined ifs because none of them should be there.

0/0
 Reply   Quote More 

Reply to All    
 

1–4

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats