🔒 Closed How just use PHP to redirect id=XX

Status
Not open for further replies.
Simply use Location header:
Code:
<?php
// program.php
$id = $_GET['id'];
switch ($id) {
 case 1:
  $your_url = 'http://localhost/link';
  break;
 case 2:
  $your_url = 'http://localhost/blog';
  break;
 default:
  $your_url = 'http://' . $_SERVER['HTTP_HOST'] . '/program.php';
  break;
}
header('Location: ' . $your_url);
exit;
?>
 
Simply use Location header:
Code:
<?php
// program.php
$id = $_GET['id'];
switch ($id) {
 case 1:
  $your_url = 'http://localhost/link';
  break;
 case 2:
  $your_url = 'http://localhost/blog';
  break;
 default:
  $your_url = 'http://' . $_SERVER['HTTP_HOST'] . '/program.php';
  break;
}
header('Location: ' . $your_url);
exit;
?>
Thank you po!
 
ts try mo kung fixed naman yung mga link mo.
lagay mo nalang sa array.

then
header('Location: ' . $array[$x]);

yung $x repesent ng index. imbis gumamit ka ng if else or switch.

PS. Suggestion lang naman. if not clear. comment ka lang
 
Status
Not open for further replies.

About this Thread

  • 5
    Replies
  • 618
    Views
  • 5
    Participants
Last reply from:
Carlowski

Trending Topics

Online now

Members online
643
Guests online
2,210
Total visitors
2,853

Forum statistics

Threads
2,299,920
Posts
29,133,657
Members
1,201,211
Latest member
SalmonSmoked
Back
Top