PHP help

Status
Not open for further replies.

lepos

thinking about you. yes you
Dec 11, 2011
2,024
687
MODERATOR CLOSE THREAD.

I'm not sure if this will make any sense at all because I don't know how to explain it, but here goes.

(This is an example), basically I have the pages
  • Index.php
  • Gallery.php
  • Contact.php
On each of the pages I'll have <?php include 'notice.php'; ?> and on the notice I want it to say "You are on the Index/Gallery/Contact page" but I want it to change according to whichever page they're on. So if they're on the gallery it'll say they're on the gallery page and if they're on the contact it will say they're on the contact page but the notice comes from the same page. Any ideas?!
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
PHP:
<?php
if ($_SERVER['PHP_SELF'] == 'contact.php'){
$notice = 'Contact'
?>
etc... probs a switch works better

EDIT: The switch

PHP:
switch ($_SERVER['PHP_SELF']) {
    case "index.php":
        echo "You are on the contact page";
        break;
    case "contact.php":
        echo "You are on the contact page";
        break;
    case "gallery.php":
        echo "You are on the gallery page";
        break;
}
 

M8than

yes
Mar 16, 2012
463
102
PHP:
<?php
$page = $_SERVER['PHP_SELF'];
switch($page){
case "index.php":
$notice="Index";
break;
case "gallery.php":
$notice "Gallery";
break;
}
?>
Etc...
 

lepos

thinking about you. yes you
Dec 11, 2011
2,024
687
PHP:
switch ($_SERVER['PHP_SELF']) {
    case "index.php":
        echo "You are on the contact page";
        break;
    case "contact.php":
        echo "You are on the contact page";
        break;
    case "gallery.php":
        echo "You are on the gallery page";
        break;
}
Decided to go with this, but it didn't work at first due to the CMS but Jak aka n0minal helped me and it's working, thanks Geen!

Ended up with
PHP:
<?php
function curPageURL() {
$pageURL .= ltrim($_SERVER["REQUEST_URI"], "/");
return $pageURL;
}
 
switch (curPageURL()) {
        case "r/me":
            echo "sex is on fire";    // me
                break;
        case "r/staff":
            echo "make love to me!";    // staff
                break;
}
?>

MODERATOR CLOSE THREAD.
 
Status
Not open for further replies.

Users who are viewing this thread

Top