[Pro] PHP redirection error in Markup item

Hi

I have a simple input form with validation made in php. The php code is placed in a Markup item in Freeway.

When I use the redirection statement header(“Location:$destination_url”) nothing happens.

When I make a php file - with exactly the same code - outside Freeway it works properly.

Any suggestions…?

Thanks
/KSP


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

What is the exact code you are using in the markup?

On May 15, 2012, at 10:25 PM, ksp wrote:

Hi

I have a simple input form with validation made in php. The php code is placed in a Markup item in Freeway.

When I use the redirection statement header(“Location:$destination_url”) nothing happens.

When I make a php file - with exactly the same code - outside Freeway it works properly.

Any suggestions…?

Thanks
/KSP


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

If you place a header() redirect anywhere except in the Before HTML section of your page, then your page will partially render, and you can’t redirect after anything has rendered. I’m surprised you don’t see the white screen of death, actually, as that’s usually a fatal error.

Walter

On May 15, 2012, at 4:25 PM, ksp wrote:

Hi

I have a simple input form with validation made in php. The php code is placed in a Markup item in Freeway.

When I use the redirection statement header(“Location:$destination_url”) nothing happens.

When I make a php file - with exactly the same code - outside Freeway it works properly.

Any suggestions…?

Thanks
/KSP


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

Hi Mike

After the form validation the “insert function.php” should be called.
Here is the code in the markup:

<?php if ( $_POST ) { $wname1 = $_POST['name1']; $wname2 = $_POST['name2']; if ($wname1 !== ' ') { $destination_url = "insertfunction.php"; header("Location:$destination_url"); exit(); } } // VALUES FROM FORM $wname1 = $_POST['name1']; $wname2 = $_POST['name2']; $wname3 = $_POST['name3']; ?>
>
>
<?php // CHECK REQUIRED FIELDS AND SET FOCUS if (empty($wname1)) { echo ""; } ?>

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

Add a space between the colon and the URL, so it reads header("Location: $destination_url");

That’s the only thing that stands out to me, you are correctly in the before HTML part of the page.

Walter

On May 15, 2012, at 5:20 PM, ksp wrote:

Hi Mike

After the form validation the “insert function.php” should be called.
Here is the code in the markup:

<?php if ( $_POST ) { $wname1 = $_POST['name1']; $wname2 = $_POST['name2']; if ($wname1 !== ' ') { $destination_url = "insertfunction.php"; header("Location:$destination_url"); exit(); } } // VALUES FROM FORM $wname1 = $_POST['name1']; $wname2 = $_POST['name2']; $wname3 = $_POST['name3']; ?>
>
>
<?php // CHECK REQUIRED FIELDS AND SET FOCUS if (empty($wname1)) { echo ""; } ?>

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

Hi Walter

Thanks for your reply. I just added a space between the colon and the URL, but without any success :frowning:

The strange thing is, when I make the exact same code from scratch in a new php file it works fine.

Freeway must be the problem here, I guess…


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

The code works for me apart from some invisible chars that appear on some of the lines, try using this code between the tildes:

<?php
if ( $_POST ) {
$wname1 = $_POST['name1'];
$wname2 = $_POST['name2'];

if ($wname1 !== ' ') {
    $destination_url = "insertfunction.php";
    header("Location:$destination_url");
    exit();
    }
}

// VALUES FROM FORM
$wname1 = $_POST['name1'];
$wname2 = $_POST['name2'];
$wname3 = $_POST['name3'];
?>

basically there are chars you don’t want that where in your code, they where before these lines:

    $destination_url = "insertfunction.php";
    header("Location:$destination_url");
    exit();
    }

I just cleared the spaced and tabed the lines of code once to the right to clear them.

HTH

On May 15, 2012, at 11:20 PM, ksp wrote:

Hi Mike

After the form validation the “insert function.php” should be called.
Here is the code in the markup:

<?php if ( $_POST ) { $wname1 = $_POST['name1']; $wname2 = $_POST['name2']; if ($wname1 !== ' ') { $destination_url = "insertfunction.php"; header("Location:$destination_url"); exit(); } } // VALUES FROM FORM $wname1 = $_POST['name1']; $wname2 = $_POST['name2']; $wname3 = $_POST['name3']; ?>
>
>
<?php // CHECK REQUIRED FIELDS AND SET FOCUS if (empty($wname1)) { echo ""; } ?>

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

Check what sort of line-feeds your Freeway document is set to generate. You want Unix LF format. Not sure what the default is.

Walter

On May 15, 2012, at 5:36 PM, ksp wrote:

Hi Walter

Thanks for your reply. I just added a space between the colon and the URL, but without any success :frowning:

The strange thing is, when I make the exact same code from scratch in a new php file it works fine.

Freeway must be the problem here, I guess…


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

Sorry for the grammatical errors in my last post… just watching TV out the side of one eye while trying to type :wink:

Freeway is definately not the issue here, I have never come across any issue with Freeway and PHP code, for me it works just as it would in a text file and I have used PHP a lot on sites.

Copy your code into a BBEdit file and switch to ‘Show invisibles’, you will see several round grey blobs, I am sure these are your problem.

HTH

On May 15, 2012, at 11:36 PM, ksp wrote:

Hi Walter

Thanks for your reply. I just added a space between the colon and the URL, but without any success :frowning:

The strange thing is, when I make the exact same code from scratch in a new php file it works fine.

Freeway must be the problem here, I guess…


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

You will get these blobs when you copy code from a poorly-formatted Web page that uses non-breaking spaces to format its code examples and paste it into Freeway’s code editing dialogs. (The correct way, since you asked, is to use

 wrapped around the code.) I have gotten them in the past from the PHP Manual site at php.net, and many many Wordpress blogs.

Walter

I had forgotten this one –
On May 15, 2012, at 5:48 PM, Mike B wrote:

Sorry for the grammatical errors in my last post… just watching TV out the side of one eye while trying to type :wink:

Freeway is definately not the issue here, I have never come across any issue with Freeway and PHP code, for me it works just as it would in a text file and I have used PHP a lot on sites.

Copy your code into a BBEdit file and switch to ‘Show invisibles’, you will see several round grey blobs, I am sure these are your problem.

HTH

On May 15, 2012, at 11:36 PM, ksp wrote:

Hi Walter

Thanks for your reply. I just added a space between the colon and the URL, but without any success :frowning:

The strange thing is, when I make the exact same code from scratch in a new php file it works fine.

Freeway must be the problem here, I guess…


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


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

Thanks…

Perhaps it’s too late for me now :slight_smile:

But I really don’t see any strange characters in BBEdit. Yes there are some grey circles, but they come whenever I type in a space. Is that want you mean?


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

I sent images through to your email address last night to show you what these grey balls looked like, did you not get them? the problem is those grey circles or blobs, balls and they need to be removed.

Typing a space should give you just that, a space.

Did you copy and paste the code I posted that has the balls removed? do you still get the issue when you use that code.

On May 16, 2012, at 12:39 AM, ksp wrote:

Thanks…

Perhaps it’s too late for me now :slight_smile:

But I really don’t see any strange characters in BBEdit. Yes there are some grey circles, but they come whenever I type in a space. Is that want you mean?


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

Thanks for your replies

I agree the problem is located to the following two lines:

$destination_url = “insertfunction.php”;

header(‘Location: $destination_url’);

Everything else works perfect.

And I’m sure getting correct into the if statement, because the exit() is performed correct.

if ($wname1 !== ’ ') {
$destination_url = “insertfunction.php”;
header(‘Location: $destination_url’);
exit();
}
}

So back to my concern :slight_smile: Can’t Freeway handle the “header Location” command?


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

On 16/05/2012, at 7:26 PM, ksp wrote:

$destination_url = “insertfunction.php”;
header(‘Location: $destination_url’);

Are the single quotes correct? See if the following works.

header(“Location: insertfunction.php”);

FWIW, I had to do a PHP redirect today. I fiddled with a variable (like above) and didn’t work. I ended up just using the URL directly and it works fine.

if (@mysql_query($sql)) {
header(“Location: http://www.torchbeta2.com/Competitions/entrysubmitted.html”);
} else {
header(“Location: http://www.torchbeta2.com/Competitions/entryfailed.html”);
}

'k


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

The problem you seem to be having was outlined in those replies I sent you and images of the actual problem where sent to you directly, did you receive those? this is where your issue * WAS * (Now it is single quotes as you have changed the code).

  1. There is no issue with PHP code and Freeway, Freeway is not the problem (That is 100%).

  2. The little balls * WHERE * your issue.

  3. The quotes you used in your original code example where not the issue either, but the single ones you are using now * ARE * the issue!

You ‘generally’ don’t put PHP variables inside single quotes or they will not be parsed, a PHP variable would go inside double quotes as you had it in your first post. You could write your code as follows:

header("Location:$destination_url");

// or

header('Location:' . $destination_url);

// or

header("Location:" . $destination_url);

// but definately not

header('Location: $destination_url');

The code will work as between the tildes below:

<?php
if ( $_POST ) {
$wname1 = $_POST['name1'];
$wname2 = $_POST['name2'];

    if ($wname1 !== ' ') {
            $destination_url = "insertfunction.php";
            header("Location:$destination_url");
            exit();
        }
    }

// VALUES FROM FORM
$wname1 = $_POST['name1'];
$wname2 = $_POST['name2'];
$wname3 = $_POST['name3'];

?>

HTH

On May 16, 2012, at 11:26 AM, ksp wrote:

Thanks for your replies

I agree the problem is located to the following two lines:

$destination_url = “insertfunction.php”;

header(‘Location: $destination_url’);

Everything else works perfect.

And I’m sure getting correct into the if statement, because the exit() is performed correct.

if ($wname1 !== ’ ') {
$destination_url = “insertfunction.php”;
header(‘Location: $destination_url’);
exit();
}
}

So back to my concern :slight_smile: Can’t Freeway handle the “header Location” command?


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