MAR - manage_result

On the front-end of my MAR demo when the form is sent it redirects to
a separate “thanks” page but instead of this I want to include a brief
inline [flash] message.

So, below is part of the controller that I modified to do this:

controller (partial code): http://pastie.org/532787

along with a screenshot of the result after submitting the form which
as you can see shows the inline message

screenshot: http://www.anoptic.com/images/mar.tiff

but also a few errors that I’ve been unable to fix in the model file:

model (partial code): http://pastie.org/532792

Todd


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

The correct url for the screenshot is <http://www.anoptic.com/MAR/images/mar.tiff

. Sorry.

Todd

On Jul 2, 2009, at 8:59 PM, Todd wrote:

On the front-end of my MAR demo when the form is sent it redirects
to a separate “thanks” page but instead of this I want to include a
brief inline [flash] message.

So, below is part of the controller that I modified to do this:

controller (partial code): http://pastie.org/532787

along with a screenshot of the result after submitting the form
which as you can see shows the inline message

screenshot: http://www.anoptic.com/images/mar.tiff

but also a few errors that I’ve been unable to fix in the model file:

model (partial code): http://pastie.org/532792


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

manage_result() needs a fourth parameter passed to it – the address of the success page – and you’re only passing it three parameters.

You could get the effect you’re after here by redirecting the page to itself, and using the regular session-based flash.

Walter


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

That’s what I’m trying to do (I think) and to an extent I did; I get
the message I want to appear above the form (see screenshot) but I
still don’t know how to fix the errors (screenshot).

T.

On Jul 2, 2009, at 10:17 PM, waltd wrote:

You could get the effect you’re after here by redirecting the page
to itself, and using the regular session-based flash.


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

The errors are happening because you’re leaving off the link to the current page as the fourth parameter to the function. Try this:

http://pastie.org/532867

Walter


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

I tried it with $self earlier tonight and all I get is a parse error:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_CASE or
T_DEFAULT or ‘}’ in/Applications/MAMP/htdocs/MAR/client/controllers/
mar_controller.php on line 3

On Jul 2, 2009, at 11:30 PM, waltd wrote:

The errors are happening because you’re leaving off the link to the
current page as the fourth parameter to the function. Try this:

http://pastie.org/532867


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

That $self = part has be outside of the switch statement. Only case
elements are allowed inside the switch. Try moving that line up to the
top of the script – get it above the line that begins with

switch ($verb){

Walter

On Jul 3, 2009, at 1:05 AM, Todd wrote:

I tried it with $self earlier tonight and all I get is a parse error:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_CASE
or T_DEFAULT or ‘}’ in/Applications/MAMP/htdocs/MAR/client/
controllers/mar_controller.php on line 3

On Jul 2, 2009, at 11:30 PM, waltd wrote:

The errors are happening because you’re leaving off the link to the
current page as the fourth parameter to the function. Try this:

http://pastie.org/532867


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


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

OK, that solves part of the problem; I thought I did put it above the
switch but in fact I mistakingly put it between the switch and case.

The form submits to the database fine but the page doesn’t redirect
back to itself and there’s an error stating that it can’t connect to
the server (I’m doing this locally) even though my local server is
clearly running.

T.

On Jul 3, 2009, at 6:32 AM, Walter Lee Davis wrote:

That $self = part has be outside of the switch statement. Only case
elements are allowed inside the switch. Try moving that line up to
the top of the script – get it above the line that begins with

switch ($verb){


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

What happens if you copy the URL out of the browser’s location window, paste it in a new window, and press return?

The form submits to the database fine but the page doesn’t redirect back to itself and there’s an error stating that it can’t connect to the server (I’m doing this locally) even though my local server is clearly running.


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

The same thing happens.

I just noticed what must be the problem. I’m running MAMP and my local
url is http://localhost:8888/MAR/client/. But when the page tries to
redirect back to itself the url shows as:
http://localhost/MAR/client/mar.

That’s got to be it, no? Question is, how do fix it.

Todd

On Jul 3, 2009, at 10:26 AM, waltd wrote:

What happens if you copy the URL out of the browser’s location
window, paste it in a new window, and press return?

The form submits to the database fine but the page doesn’t redirect
back to itself and there’s an error stating that it can’t connect
to the server (I’m doing this locally) even though my local server
is clearly running.


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

Easy. Just be more thorough about creating $self.

$self = 'http://' . $_SERVER['SERVER_NAME'];
$self .= ($_SERVER['SERVER_PORT'] != '80') ? ':' .  
$_SERVER['SERVER_PORT'] : '';
$self .= $_SERVER['REQUEST_URI'];

That should fix things for you. Naturally, on a real Apache running by
default in port 80, none of these shenanigans are required.

Walter

On Jul 3, 2009, at 11:33 AM, Todd wrote:

The same thing happens.

I just noticed what must be the problem. I’m running MAMP and my
local url is http://localhost:8888/MAR/client/. But when the page
tries to redirect back to itself the url shows as:
http://localhost/MAR/client/mar.


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

That fixed the redirect error but the flash message doesn’t appear
now, the page reloads with no indication of the form being sent (which
it is). I quickly tried it on the live server without all the hoop-
jumping below and the result is the same, no errors but no message
either.

T.

On Jul 3, 2009, at 10:48 AM, Walter Lee Davis wrote:

Easy. Just be more thorough about creating $self.

$self = 'http://' . $_SERVER['SERVER_NAME'];
$self .= ($_SERVER['SERVER_PORT'] != '80') ? ':' .  
$_SERVER['SERVER_PORT'] : '';
$self .= $_SERVER['REQUEST_URI'];

That should fix things for you. Naturally, on a real Apache running
by default in port 80, none of these shenanigans are required.

Walter

On Jul 3, 2009, at 11:33 AM, Todd wrote:

The same thing happens.

I just noticed what must be the problem. I’m running MAMP and my
local url is http://localhost:8888/MAR/client/. But when the page
tries to redirect back to itself the url shows as:
http://localhost/MAR/client/mar.


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


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

I suspect it’s either being eaten somewhere, or you are trying to
print $flash instead of $_flash. See what happens if you put
print_r($_SESSION) somewhere high up in your script, before any
instance of anything that looks like if(isset($_SESSION....

Remember, you are getting this value out of the session after a full
redirect like this. The $flash (normal page variable) is for error
messages (usually) because the page doesn’t get a full reload, it just
fails through to the form, and the session is only populated after a
full reload.

Walter

On Jul 3, 2009, at 12:00 PM, Todd wrote:

That fixed the redirect error but the flash message doesn’t appear
now, the page reloads with no indication of the form being sent
(which it is). I quickly tried it on the live server without all the
hoop-jumping below and the result is the same, no errors but no
message either.

T.

On Jul 3, 2009, at 10:48 AM, Walter Lee Davis wrote:

Easy. Just be more thorough about creating $self.

$self = 'http://' . $_SERVER['SERVER_NAME'];
$self .= ($_SERVER['SERVER_PORT'] != '80') ? ':' .  
$_SERVER['SERVER_PORT'] : '';
$self .= $_SERVER['REQUEST_URI'];

That should fix things for you. Naturally, on a real Apache running
by default in port 80, none of these shenanigans are required.

Walter

On Jul 3, 2009, at 11:33 AM, Todd wrote:

The same thing happens.

I just noticed what must be the problem. I’m running MAMP and my
local url is http://localhost:8888/MAR/client/. But when the page
tries to redirect back to itself the url shows as:
http://localhost/MAR/client/mar.


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


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


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

I assume you mean in the controller and when I do it throws an error.

T.

On Jul 3, 2009, at 11:11 AM, Walter Lee Davis wrote:

I suspect it’s either being eaten somewhere, or you are trying to
print $flash instead of $_flash. See what happens if you put
print_r($_SESSION) somewhere high up in your script, before any
instance of anything that looks like if(isset($_SESSION....


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

Hmmm. I’m out of suggestions, then. Without seeing the error or the
script running, it’s pretty hard to trace where the session is
disappearing to.

Walter

On Jul 3, 2009, at 12:47 PM, Todd wrote:

I assume you mean in the controller and when I do it throws an error.

T.

On Jul 3, 2009, at 11:11 AM, Walter Lee Davis wrote:

I suspect it’s either being eaten somewhere, or you are trying to
print $flash instead of $_flash. See what happens if you put
print_r($_SESSION) somewhere high up in your script, before any
instance of anything that looks like if(isset($_SESSION....


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


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

I can put everything online or I can send you link to my local file(s)
using Coda so you can see everything. Let me know what’s preferable.

T.

On Jul 3, 2009, at 12:06 PM, Walter Lee Davis wrote:

Hmmm. I’m out of suggestions, then. Without seeing the error or the
script running, it’s pretty hard to trace where the session is
disappearing to.


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

Since you’re running this in MAMP, I don’t know what I could do from
here unless we used Timbuktu or similar. Even if you posted it on a
real server, you’d need to give me SSH privileges on that server so I
could tweak things…

Pity Chicago and Philadelphia aren’t closer to one another…

Walter

On Jul 3, 2009, at 1:12 PM, Todd wrote:

I can put everything online or I can send you link to my local
file(s) using Coda so you can see everything. Let me know what’s
preferable.

T.

On Jul 3, 2009, at 12:06 PM, Walter Lee Davis wrote:

Hmmm. I’m out of suggestions, then. Without seeing the error or the
script running, it’s pretty hard to trace where the session is
disappearing to.


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


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

Well, if I sent you the Coda link you could at least look at the file
and see if I putzed something up. I could still run it on my end
through MAMP to check it. As for giving you SSH priv. I’m willing to
do that but I’m not sure how. I’ll have a look in my cp.

Todd

On Jul 3, 2009, at 12:18 PM, Walter Lee Davis wrote:

Since you’re running this in MAMP, I don’t know what I could do from
here unless we used Timbuktu or similar. Even if you posted it on a
real server, you’d need to give me SSH privileges on that server so
I could tweak things…


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