Jump to content

redirect not working


Goldi90

Recommended Posts

Hi,

how to redirect to another page ...

if ($_GET['autor'] && $_GET['ulr']){
$niepl = intval($_GET['autor']);
$ulr = urldecode($_GET['ulr']);
header('Location: http://www.adrtes.pl/mp3/'.$ulr.'/'.$niepl.'.html');
}

while ($row = mysqli_fetch_array($sql)) {   
$niepl = $row['autor'];
$we1 = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż',' ');
$wy1 = array('a','c','e','l','n','o','s','z','z','A','C','E','L','N','O','S','Z','Z','-');
$niepl= str_replace($we1, $wy1, $niepl);

echo '<strong><a href="'.$row['ulr'].'/'.$niepl.'" title='.$row['tytul'].'>'.$row['tytul'].'</a></strong>';

 

My link looks like this:

http://www.adress.pl/bo/Name-That/Autore-Yourself

 

and is redirected to the address

http://www.adrtes.pl/mp3/Name-That/Autore-Yourself.html

 

Changes only: Name-That and Autore-Yourself

Link to comment
Share on other sites

first do this and make sure your getting the variables

 

if ($_GET['autor'] && $_GET['ulr']){
$niepl = intval($_GET['autor']);
$ulr = urldecode($_GET['ulr']);
echo "ulr=$ulr - niepl=$niepl";
// header('Location: http://www.adrtes.pl/mp3/'.$ulr.'/'.$niepl.'.html');
}

 

if that echos the 2 variables you want then do your redirect like this

 

if ($_GET['autor'] && $_GET['ulr']){
$niepl = intval($_GET['autor']);
$ulr = urldecode($_GET['ulr']);
header("Location: http://www.adrtes.pl/mp3/$ulr/$niepl.html");
}

Link to comment
Share on other sites

1. nothing appears

 

2. not work

 

All code:

<?php
if ($_GET['autor'] && $_GET['uri']){
$autor = urldecode($_GET['autor']);
$uri = urldecode($_GET['uri']);
header('Location: http://www.adrtes.pl/mp3/'.$ulr.'/'.$niepl.'.html');
}

$db = new mysqli('localhost','xxxx_xxxx','xxxxx','xxxx_xxxx');
mysqli_query($db,'SET NAMES `utf8`');
$wykonaj=mysqli_query($db,"SELECT * FROM `no` ORDER BY `pub_id` DESC ");
$znaleziono=mysqli_num_rows($wykonaj);
$sql = mysqli_query($db,'SELECT * FROM `no` ORDER BY `pub` DESC  ');

while ($row = mysqli_fetch_array($sql)) {

$autor = $row['autor'];
$we1 = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż','
');
$wy1 = array('a','c','e','l','n','o','s','z','z','A','C','E','L','N','O','S','Z','Z','-');
$autor= str_replace($we1, $wy1, $autor);

       echo '<div class="prod_title"><strong><a
href="'.$row['uri'].'/'.$autor.'"
title='.$row['tytul'].'>'.$row['tytul'].'</a></strong> </div>';
}
?>

 

What do you want to achieve ... links in the form of www.mojadres.pl/$row['uri']/$author

(eg www.mojadres.pl/Ble-ble/Autoros-autorex - it is already

achieved through the <a href ="'.$ row['uri'].'/'.$author.' "

title = '. $row[' title'].'>'.$ row['title'].'</ a>)

These links above are to be redirected to this address

http://www.adres.pl/pub/ '. $ uri .'/'.$ author.'. html - or entering into

my link www.mojadres.pl/Ble-ble/Autoros-autorex have been

redirected to http://www.adres.pl/pub/ble-ble/autoros-autorex.html

etc.

Link to comment
Share on other sites

how are you sending the variable autor and uri to this page?

 

to use $_GET the variables need to be in a form with the get method used or placed at the end of a page link to a page that will use them

 

eg

 

<a href="http://www.adrtes.pl/redirect.php?autor=somevalue&uri=anothervalue">Some text link</a>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.