๐Ÿ”’ Closed How just use PHP to redirect id=XX

Status
Not open for further replies.

dustatlantis

Honorary Poster
Is any way to help me how to program this one? Hard to edit contexts one by one.
1672244138089.webp
 
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
  • 609
    Views
  • 5
    Participants
Last reply from:
Carlowski

Trending Topics

Online now

Members online
1,080
Guests online
1,403
Total visitors
2,483

Forum statistics

Threads
2,277,060
Posts
28,974,064
Members
1,229,711
Latest member
------
Back
Top