|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
how would you create a link in php from one page to another, im guessing the
header ('Location http://www.etc.com'); as im building an index file - i want when the user clicks on a button hyperlink they will be redirected to that other page from within the index.php file Any thoughts? thanks everybody |
|
#2
|
||||
|
||||
|
__________________
|
|
#3
|
|||
|
|||
|
lol, nah i mean i am including files, how could i create a variable so when the user clicks on the hyperlink and only then the information from the other script will be included within the index file.
as i will have numerous of these below making it easier for my template condition here?? include("sdadasd.php"); cheers |
|
#4
|
||||
|
||||
|
User interaction is done client side, PHP is run server side. You would have to do this with AJAX which if I understand what you want correctly, would probably be overkill. You can use Javascript and CSS to hide or show content that is written into the HTML document to start with. PHP can write that document, but it's up to Javascript/CSS from there to do anything in response to what the user does.
__________________
"Strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony! Well, but you can't expect to wield supreme executive power just 'cause some watery tart threw a sword at you! I mean, if I went 'round saying I was an emperor just because some moistened bint had lobbed a scimitar at me, they'd put me away!" |
|
#5
|
||||
|
||||
|
If you mean something like index.php?page=one shows one page and index.php?page=two shows another, then it's simple.
$_GET["page"] is the "one" or "two" from above. Just check whether it matches a certain string, and include() the right file if it does. PHP Code:
__________________
Oyashiro-sama...
If something "isn't working" then EXPLAIN WHY. Tell us what it should do, and then what it does do.PHP Manual (cURL - PCRE regex - references) error_reporting() SQL injection: and mysql_real_escape_string() PHP and cron Negative0 |
|
#6
|
|||
|
|||
|
You're referring to what is commonly known as the front controller pattern. The example requinix provided illustrates this nicely; you can take this one step further and create some rewrite rules in a .htaccess file (if your host serves PHP via Apache) that direct the user to this script via separate URLs, e.g.
Code:
RewriteEngine On RewriteRule ^one\/?$ index.php?page=one [L] RewriteRule ^two\/?$ index.php?page=two [L] So the users access these via yourdomain.com/ (default action) yourdomain.com/one (index.php?page=one) etc As a fallback, if the user tries to access anything else, they will be shown the default page, e.g. yourdomain.com/foo (still shows the default index)
__________________
BookMooch.com : Give books away. Get books you want. |
|
#7
|
|||
|
|||
|
cheers thanks a lot everybody for your help, managed to do it sucessfully first go, no errors which is a first!!!
![]() |
|
#8
|
|||
|
|||
|
heya, im havin a few problems with the code..
Heya this code is included from another file into the indexadp.php fileCode:
<li><a href="<?php echo WEB_ROOT; ?>indexadp.php"> Home</a></li> <li><a href="<?php echo WEB_ROOT; ?>indexadp.php?page=one" >Category</a></li> <li><a href="<?php echo WEB_ROOT; ?>indexadp.php?page=two" >Product</a></li> <li><a href="<?php echo WEB_ROOT; ?>indexadp.php?page=three" >Order</a></li> <li><a href="<?php echo WEB_ROOT; ?>indexadp.php?page=four" >Shop Config</a></li> <li><a href="<?php echo WEB_ROOT; ?>indexadp.php?page=six" >User</a></li> <li><a href="<?php echo $self; ?>?logout" >Logout</a></li> this is my code as it stands, it comes up with the error: Parse error: syntax error, unexpected T_LNUMBER PHP Code:
Last edited by ford2008 : May 12th, 2008 at 03:11 PM. Reason: error occuring |
|
#9
|
|||
|
|||
|
What's this line supposed to do?
PHP Code:
is it supposed to be PHP Code:
Quote:
|
|
#10
|
||||
|
||||
|
First, don't use backslashes (\) for the include()d files. Use forward slashes (/) instead.
Second: Are you posting all the code? What line number is the error occurring on? |
|
#11
|
|||
|
|||
|
o yea
cool iv changed the slashes and now it comes up with that i cant find include files, guess the addresses are wrong for the include files?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > How would you do this? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|