...

View Full Version : Redirect stuff



Dat
09-17-2009, 07:48 AM
So I wanna create redirects after a form is complete.

Here is how it goes, I have the information page and "edit new info" link, which links to the form to edit new info. And... i have another link on the Control panel page which also links to the form to edit info. I want it so if i submit a form i can go back to w/e page I originated from.

info page -> Form -> info page
CP page -> Form -> CP page

So what i created is this a link

Example:


<a href="www.domain.com/cp/form.php?category=apple&id=1&redirect=www.domain.com/cp/?category=apple&id=1">Edit category</a>

Obviously you see the prob the redirect $_GET stops after apple cause of the '&'

Any solutions?

Fou-Lu
09-17-2009, 08:40 AM
Encode the string before passing it through the url: http://php.ca/manual/en/function.urlencode.php

Dat
09-17-2009, 05:22 PM
Thanks but why doesn't this work?


$link = '/anime/?id='.$data_entry['entry_id'].'&type=anime';
$link = urlencode($link);

SKDevelopment
09-17-2009, 05:27 PM
Thanks but why doesn't this work?


$link = '/anime/?id='.$data_entry['entry_id'].'&type=anime';
$link = urlencode($link);
Because it should be


$link = '/anime/?id=' . urlencode($data_entry['entry_id']) . '&type=anime';

You should urlencode only values in the query string, not the whole URL.

Dat
09-18-2009, 03:24 AM
Because it should be


$link = '/anime/?id=' . urlencode($data_entry['entry_id']) . '&type=anime';
You should urlencode only values in the query string, not the whole URL.
but im trying to encode that url: '/anime/?id='.$data_entry['entry_id'].'&type=anime'

/anime/?id=6&type=anime if it gives you a better understanding.

So... i want the link to be like <a href="www.domain.com/cp/edit.php?id=6&type=anime&rd=%2Fanime%2F%3Fid%3D6%26type%3Danime ">Edit this</a>

Dat
09-18-2009, 05:00 AM
Okay so i tested the urlencode() function by copying a test from google.


<?php

$s = "This is a test string";

$url = "urlencode.php?data=" . urlencode($s);
print "<a href=\"$url\">Click me</a><br>";
if (isset($_REQUEST["data"])) {
print "URL: " . $_SERVER['REQUEST_URI'] . "<br>";
print "Decoded data: " . urldecode($_REQUEST["data"]);
}

?>

It doesn't work wtf?

PappaJohn
09-18-2009, 05:15 AM
That code works exactly as expected for me.

Output:


URL: /urlencode.php?data=This+is+a+test+string
Decoded data: This is a test string

Dat
09-18-2009, 06:34 AM
That code works exactly as expected for me.

Output:


URL: /urlencode.php?data=This+is+a+test+string
Decoded data: This is a test string


It works now >.< Bangs on table.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum