[Pro] Run php script in a window?

I have a php script to handle mailing list subscriptions which was supplied by the software company. I would like to run this is a window so that it looks more in-keeping with the rest of my site.

Any way to do this?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sure. Freeway can be used with PHP in a number of different ways, depending on the script. Can you post that script on Gist or Pastie (make sure there aren’t any passwords or other sensitive info in there first) and one of us can take a look at it and advise. It might need some surgery (the script may already implement a rudimentary user interface, which would need to be moved into Freeway and removed from the script) but it should be do-able.

Walter

On Feb 13, 2013, at 3:40 AM, Kevin Cheesman wrote:

I have a php script to handle mailing list subscriptions which was supplied by the software company. I would like to run this is a window so that it looks more in-keeping with the rest of my site.

Any way to do this?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Gist or Pastie - what’s this?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

https://gist.github.com or http://pastie.org

Free sites where you can paste any sort of code, and others can read it without any server-side filtering taking place. (If you post a PHP script on a Web server that has PHP enabled, the only thing anyone can see is the output of that script, not the script itself. This is how PHP works.)

Walter

On Feb 13, 2013, at 7:59 AM, Kevin Cheesman wrote:

Gist or Pastie - what’s this?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

<?php //--SETTINGS-------------------------------------------------------------------- $lm_path = "../lm.php"; // The path of the MLM script //--DEBUGING-------------------------------------------------------------------- $mlm_debug = False; if ( $mlm_debug ) { error_reporting(E_ALL); ini_set('display_errors','on'); } else { error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors','off'); } //--PARAMATER CHECKING---------------------------------------------------------- if ( isset( $_REQUEST['cmd'] ) && !empty( $_REQUEST['cmd'] ) ) { $cmd = $_REQUEST['cmd']; } if ( isset( $_REQUEST['email'] ) && !empty( $_REQUEST['email'] ) ) { $email = $_REQUEST['email']; } if ( isset( $_REQUEST['list'] ) && !empty( $_REQUEST['list'] ) ) { $list = $_REQUEST['list']; } else { $list = "list1"; } if ( isset( $_REQUEST['firstname'] ) && !empty( $_REQUEST['firstname'] ) ) { $firstname = $_REQUEST['firstname']; } if ( isset( $_REQUEST['lastname'] ) && !empty( $_REQUEST['lastname'] ) ) { $lastname = $_REQUEST['lastname']; } //-- INTERNAL PARAMETERS ------------------------------------------------------- $script_file = $_SERVER["SCRIPT_NAME"]; $script_path = Explode( '/', $script_file ); $script_name = $script_path[ count( $script_path ) - 1 ]; //-- PARAMETER CHECKER & ERROR HANDING ----------------------------------------- if ( isset( $_REQUEST['submit'] ) ) { $errors = array(); if ( $email == "" ) { $errors[] = "Enter your email address in the email address text box"; $wrong['email'] = TRUE; } if ( $email !== "" && ( stristr( $email, "." ) == FALSE || stristr( $email, "@" ) == FALSE ) ) { $errors[] = "The e-mail address you have entered is not valid"; $wrong['email'] = TRUE; } if ( $firstname == "" ) { $errors[] = "Enter your first name in the first name text box"; $wrong['firstname'] = TRUE; } if ( $lastname == "" ) { $errors[] = "Enter your last name in the last name text box"; $wrong['lastname'] = TRUE; } if ( count( $errors ) == 0 ) { $url = $lm_path . "?cmd=$cmd&list=$list&email=$email&firstname=$firstname&lastname=$lastname"; header("Location: $url"); } } ?>
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	<meta name="generator" content="Adobe GoLive" />
	<title>Mailing List Subscription</title>
	<style type=text/css>
		A:link  { color: #396D84; font-weight: normal; text-decoration: underline }
		A {
			CURSOR: hand; TEXT-DECORATION: none
		}
		A:visited  { color: #396D84; font-weight: normal; text-decoration: underline }
		A:active  { color: #86B82D; text-decoration: underline }
		A:hover   { color: #86B82D; font-weight: normal; text-decoration: underline }
		
		input[type="text"], input[type="password"], textarea {font-weight: bold;}
		select:focus, textarea:focus, input:focus {background-color: #ffffee;}
	</style>
</head>

<body>
	<div align="center">
		<br />
		<br />
		<table width="500" border="0" cellspacing="2" cellpadding="0">
			<tr bgcolor="#0059a5" height="22">
				<td height="22">
					<div align="center">
						<font color="white" face="Verdana, Arial, Helvetica, sans-serif"><b>Mailing List Subscription</b></font></div>
				</td>
			</tr>
			<tr bgcolor="white" height="16">
				<td height="16"></td>
			</tr>
			<tr>
				<td>
					<div align="center">
						<form id="FormName" action="<?php echo $script_name; ?>" method="get" name="FormName">
							<table width="100%" border="0" cellspacing="2" cellpadding="0">
								<tr height="24">
									<td width="40%" height="24">
										<div align="right">
											<font size="-1" color="#0059a5" face="Verdana"><b>Your E-mail Address</b></font></div>
									</td>
									<td width="15" height="24"></td>
									<td height="24"><input type="text" name="email" size="30" <?php echo " value="$email""; ?> /></td>
									<td height="24"><font size="-2" color="#ff9c9c" face="Geneva,Arial,Helvetica,sans-serif">Required</font></td>
								</tr>
								<tr height="24">
									<td width="40%" height="24">
										<div align="right">
											<font size="-1" color="#0059a5" face="Verdana"><b>Your First Name</b></font></div>
									</td>
									<td width="15" height="24"></td>
									<td height="24"><input type="text" name="firstname" size="30" <?php echo " value="$firstname""; ?> /></td>
									<td height="24"><font size="-2" color="#ff9c9c" face="Geneva,Arial,Helvetica,sans-serif">Required</font></td>
								</tr>
								<tr height="24">
									<td width="40%" height="24">
										<div align="right">
											<font size="-1" color="#0059a5" face="Verdana"><b>Your Last Name</b></font></div>
									</td>
									<td width="15" height="24"></td>
									<td height="24"><input type="text" name="lastname" size="30" <?php echo " value="$lastname""; ?> /></td>
									<td height="24"><font size="-2" color="#ff9c9c" face="Geneva,Arial,Helvetica,sans-serif">Required</font></td>
								</tr>
								<tr height="24">
									<td width="40%" height="24">
										<div align="right">
											<input type="hidden" name="list" value="<?php echo $list; ?>" /></div>
									</td>
									<td width="15" height="24"></td>
									<td height="24"><input type="radio" name="cmd" value="subscribe" <?php if ( $cmd == "" || $cmd == "subscribe" ) { echo "checked="checked""; } ?> /><font size="2" face="Arial"> Subscribe <input type="radio" name="cmd" value="unsubscribe" <?php if ( $cmd == "unsubscribe" ) { echo "checked="checked""; } ?> /> Unsubscribe</font></td>
									<td height="24"></td>
								</tr>
								<tr height="20">
									<td colspan="3" valign="top" height="20"></td>
									<td valign="top" height="20"></td>
								</tr>
								<tr>
									<td width="40%">
										<div align="center"></div>
									</td>
									<td width="15"></td>
									<td>
										<div align="right">
											<font size="-1" face="Verdana"><b><input type="submit" name="submit" value="Submit" /> <input type="reset" value="Clear Form" /></b></font></div>
									</td>
									<td></td>
								</tr>
							</table>
						</form>
					</div>
				</td>
			</tr>
			<tr height="10">
				<td height="10">
					<div align="center">
						<?php

// — ERROR CHECKING —

if ( isset( $_REQUEST[‘submit’] ) ) {
if ( count( $errors ) > 0) {
echo “
”;
echo “

”;
echo “”;
echo “”;
echo “”;
echo “
”;
echo “
”;
echo “Sorry but we can’t process your request
”;
echo “
”;
echo “”;
echo “Please fix the following issues</b/>
”;
for($i=0; $i<count($errors); $i++){
echo $errors[$i].“
”;
}
} else if ( count( $successes ) > 0) {
echo “”;
echo “Your request has been processed successfully:</b/>
”;
for($i=0; $i<count($successes); $i++){
echo $successes[$i].“
”;
}
}
}

?>







Maxprog List Manager v1.0 - Max Programming, LLC - Copyright (c) 2008 - 2009










freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This looks perfectly translate-able, assuming you have read and edited PHP before. Open up this script in a programmer’s text editor (TextWrangler is free, I use TextMate 1.5, but that’s not free). Unlike a general purpose tool like TextEdit, a programmer’s text editor will highlight different types of code with different colors, and some will show you syntax errors very vividly, too!

Look through the script for each block of PHP code. These begin with <?php and end with ?>, which are known as delimiters. Everything in between those two markers is an executable program. As you move through the script, you will also see the cardinal points of the HTML page that is interwoven into the page. These are mostly not inside of the PHP delimiters (except where there is a loop building a table). The first big block of code appears before the opening tag.

So in Freeway, starting on a new blank page, you open the Page / HTML Markup, switch to Before HTML, and paste in that entire opening block of code, including the PHP delimiters at beginning and end.

Back in your text editor, skip over the HTML that follows until you come to the next bit of PHP. In my reading of this, that would be the action attribute of the form tag. So in Freeway, open up Form Setup, set the Method to GEET, and in the Action field, paste in the relevant bit of PHP: <?php echo $script_name; ?>

Repeat for the e-mail form element. There, you will need to draw (or better, insert into a table cell) a text input. Set the name (third tab of the Inspector) to email and the value to a slight variation on their code. They have the entire value attribute definition within the PHP, but that won’t create valid HTML in Freeway, so you need to change this:

<?php echo " value="$email""; ?>

to this:

<?php echo $email; ?>

and paste that into the Value field in the third tab of the Inspector.

Repeat this process for the firstname and lastname fields, with the equivalent editing in each.

Next in source order is a hidden field for the list ID. In Page / Form Setup, open up the Hidden Fields tab, and click new. The Name is ‘list’ and the value will be <?php echo $list; ?>

Next is the radio buttons for the action you wish to take. This gets fairly complex in Freeway, because the checked attribute needs to be added depending on the value set for that group. I just uploaded a simple Action called RadioFlyer to ActionsForge that will help you here. Create your two radio buttons, naming them both ‘cmd’ and setting their value to ‘subscribe’ or ‘unsubscribe’. Apply RadioFlyer to each of them. That will write out the next bit of PHP for you, so you are nearly there!

The last step is to add the Submit button, and be sure it is named ‘submit’ in the third tab of the Inspector. Whatever you enter in the Value field will become the text on the face of the button.

The last blob of PHP in the page is the error reporting script. Copy that out and in your page, create a Markup Item where you want it to appear. Paste the code into the Markup Item’s code window, then okay it and resize and reposition it to where you want the errors to appear.

At this point, you have to change the filename of the page to end in .php. Do that in the Page Inspector, in the File field on the first tab. Once you do, you won’t be able to preview the page in Freeway or a browser. You will only be able to see it if you upload it to a server that has PHP running and visit that page from its public URL.

Walter

On Feb 13, 2013, at 8:34 AM, Kevin Cheesman wrote:

<?php

freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks for this. I’ll get to work in it soon.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options