Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page need to redirect with URL parameters code
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Member
nanotech is on a distinguished road
 
Posts: 41
Join Date: Apr 2012
Default need to redirect with URL parameters code - 07-08-2012, 09:13 PM

i would like to know what kind of code could i use to proceed the following way into a file called execute.php


like


A) h**p://www.example-a.com/?ct=&s=1&m=10&n=none[/url]

B) h**p://www.example-a.com/?ct=&s=2&m=20&n=none[/url]

C) h**p://www.example-a.com/?ct=&s=3&m=30&n=none[/url]

D) h**p://www.example-a.com/?ct=&s=4&m=40&n=none[/url]



list.php

<php?

A) $link_1 = 'www.site-a.com';

B) $link_2 = 'www.site-b.com';

C) $link_3 = 'www.site-c.com';

D) $link_4 = 'www.site-d.com';

?>


like

upper line A) redirect with lower line A)

upper line B) redirect with lower line B)

upper line C) redirect with lower line C)

and so on

by using eather one of these parameters s= or m=

the list.php file would be included into the execute.php code file


any help appreciated
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Doug Lochert's Avatar
Senior Member
Doug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond repute
 
Posts: 416
Join Date: Jun 2012
Default 07-09-2012, 04:23 PM

From what I can only assume, it appears you may be looking to utilize the PHP $_GET and switch functions.

With $_GET you can use php encoded urls like in fig. 1

To use the $_GET function you define $_GET by "case" (at the top of your execute.php page, before parsing any further data/output on the page).

Example execute.php:
Code:
$link_1 = 'www.site-a.com';
$link_2 = 'www.site-b.com';
$link_3 = 'www.site-c.com';
$link_4 = 'www.site-d.com';

$action = $_GET['action'];
switch ($action) {
     case '1':
            header("Location:$link_1");
     case '2':
            header("Location:$link_2");
     case '3':
            header("Location:$link_3");
     case '4':
            header("Location:$link_4");
     }
Sample php encoded urls for the above might be something like:
Code:
<a href="dir/execute.php?action=1">Link 1</a>
<a href="dir/execute.php?action=2">Link 2</a> 
<a href="dir/execute.php?action=3">Link 3</a>
<a href="dir/execute.php?action=4">Link 4</a>
The above is a "simplified" script sample (for ease of use).




Last edited by Doug Lochert; 07-09-2012 at 04:37 PM.
Reply With Quote
(#3 (permalink))
Old
Member
nanotech is on a distinguished road
 
Posts: 41
Join Date: Apr 2012
Default 07-09-2012, 05:16 PM

just to point you out that these example hyperlinks will be in the email i send to my subscribers
example:

welcome to my-web-site(dot)com

if you want to contact me click on the link bellow


h**p://www.my-website.com/?ct=&s=1&m=10&n=none

for any other info click

h**p://www.my-website.com/?ct=&s=1&m=20&n=none


thank's webmaster



in the above example each hyperlinks has to redirect by clicking to a specific external urls

the hyperlink allready part of the email

by selecting the proper query for each of the dedicated url above

with the URL strings included in the list.php file

like

query s=1 going to redirect to site $A (in list.php)

query s=2 going to redirect to site $B (in list.php)

and so on

only by clicking the hyperlink part of the sended email

Last edited by nanotech; 07-09-2012 at 05:19 PM.
Reply With Quote
(#4 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 762
Join Date: Dec 2010
Default 07-11-2012, 01:17 AM

If list.php file is something like:

$A = "http://www.my-website.com/?ct=&s=1&m=10&n=none";
$B = "http://www.my-website.com/?ct=&s=1&m=20&n=none";

your redirect file should be written similar to below:

Code:
<?php include "list.php"; ?>

If you want to contact me click on the link below:

<a href='<?php echo $A; ?>'>Link 1</a>

For any other info click 

<a href='<?php echo $B; ?>'>Link 2</a>

Last edited by grace1004; 07-11-2012 at 02:08 AM.
Reply With Quote
(#5 (permalink))
Old
Member
nanotech is on a distinguished road
 
Posts: 41
Join Date: Apr 2012
Default 07-11-2012, 01:41 PM

can i use

header ( ' Location: $A ' );

instead included in the list.php

to redirect from the index.php file

so that if the subcriber click on the email hyperlink

it will redirect it to list.php than execute the redirect via

header ( ' Location: $A ' );

Last edited by nanotech; 07-11-2012 at 01:55 PM.
Reply With Quote
(#6 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 762
Join Date: Dec 2010
Default 07-11-2012, 02:40 PM

The following is an example of header() for redirect (please refer to
http://php.net/manual/en/function.header.php).

header("Location: http://www.example.com/");

Based on the above example, I changed the code as shown below.
So, please try the following codes and see if it works.

$A = http://www.my-website.com/?ct=&s=1&m=10&n=none;
$B = http://www.my-website.com/?ct=&s=1&m=20&n=none;

header("Location: $A");
header("Location: $B");

Last edited by grace1004; 07-12-2012 at 01:37 AM.
Reply With Quote
(#7 (permalink))
Old
Member
nanotech is on a distinguished road
 
Posts: 41
Join Date: Apr 2012
Default 07-11-2012, 11:27 PM

ok found my problem it was that i inserted a line with print syntax BEFORE

the header function it is a mistake that i didnt know shouln't be done in php

code

last question



i would like to merger two variable name to make one

EX: $Question_$B together to make $Question_1 by name but $B would = 1

or $Answer_$A to make $Answer_3 but $A would be = 3 or anything else

like $Answer_3 and so on is there a way to do so

like a rename string function
Reply With Quote
(#8 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 762
Join Date: Dec 2010
Default 07-12-2012, 01:30 AM

To merge strings, you can use concatenation operator ('.'). For details, please refer to
http://php.net/manual/en/language.operators.string.php.

I did not clearly understand your explanation, but try the following code:

PHP Code:
$B l;

$Question_1 $Question."_".$B;

$A 3;

$Answer_3 $Answer."_".$A
Reply With Quote
(#9 (permalink))
Old
Member
nanotech is on a distinguished road
 
Posts: 41
Join Date: Apr 2012
Default 07-15-2012, 11:14 PM

i did something like this for code

Example:

<?php

$Value_ A = 1 ;

$Value_ A = 2 ;

$Site = ${'Website_'.($Value_A + $Value_B)};

print "$Site";

?>

will display

$Website_3

on the screen

work real nice but took a while to figure it out

thank's for the tips

Nano

Last edited by nanotech; 07-15-2012 at 11:20 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com