Does anyone know if it is possible through the use of php to point a link (<a href="">) to a specific file in which all of the links are controlled? My reason behind this is that, although I already use the include function to minimize the amount of code, I may have links within the body of each page that are the same as on another page. Instead of having to go into each file to edit the url I would like to be able to edit and control the url's within one specific file (links.php).
Brandon
Point ahref to links.php(which controls all links)possible?
Moderator: General Moderators
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Point ahref to links.php(which controls all links)possible?
Sure, it's possible, almost trivial actually if you're willing to use header redirects.
Re: Point ahref to links.php(which controls all links)possible?
I got the answer from "robnet" who suggested I use constants similiar to described below.
home.php
and, pages.php
This worked great and allows me to control all links within pages.php. However, now I'm having trouble using the same piece of code for the forms (login.php and register.php).
I tried the below code, but that did not work; it just redirected me to home.php.
Also how might you do this if you are already inside with the php brackets?
EXAMPLE
Any ideas?
Brandon
home.php
Code: Select all
?php require_once('pages.php'); echo "<a class='alt' href=". www_register.">Register</a>"; ?>
?php require_once('pages.php'); echo "<a class='alt' href=". www_process.">Login</a>"; ?>
Code: Select all
<?php
define('www_root','http://localhost/youinfer_/');
define('www_register',www_root.'register.php');
define('www_process',www_root.'login.php');
?>
I tried the below code, but that did not work; it just redirected me to home.php.
Code: Select all
Code: Select all
<?php require_once('pages.php'); echo "<form action=". www_process.">"; ?>
EXAMPLE
Code: Select all
<a href="http://localhost/youinfer_/userinfo.php ?user=<?php echo $session->username; ?>"> Profile</a>Brandon