[SOLVED] newbie question
Moderator: General Moderators
[SOLVED] newbie question
Hello again .
I have a small quick question please.
when there's websites with like index.php=contact..
and it goes to the contact page..
how it called when you do something like that ?
just the name..I wanna learn how to do that..
Thanks alot..
I have a small quick question please.
when there's websites with like index.php=contact..
and it goes to the contact page..
how it called when you do something like that ?
just the name..I wanna learn how to do that..
Thanks alot..
- smpdawg
- Forum Contributor
- Posts: 292
- Joined: Thu Jan 27, 2005 3:10 pm
- Location: Houston, TX
- Contact:
If you are using Apache, you can use url rewriting to translate a URL from a more readable form to something that works with PHP.
If you want to have a URL like this:
http://www.somesite.com/test.php?contact
You just need to look at $_SERVER['QUERY_STRING'] and you will see what is after the question mark.
edit - Too fast feyd, you beat me to it.
If you want to have a URL like this:
http://www.somesite.com/test.php?contact
You just need to look at $_SERVER['QUERY_STRING'] and you will see what is after the question mark.
edit - Too fast feyd, you beat me to it.
yeah..
I know its common in PHP..
I've made this..
http://oktober.co.il/rafi/test/new/contact.php
using
<form method="post" action="mail.php?act=contact">
and then it goes to mail.php?act=contact
but i'd like to do that without POSTING anything..
I've find this Tutorial
http://www.freewebmasterhelp.com/tutorials/php/6
its looks like exactly what I want to do..but I make out anthing..
$variablename=$_POST['variable'];
$variablename=$_GET['variable'];
I know its common in PHP..
I've made this..
http://oktober.co.il/rafi/test/new/contact.php
using
<form method="post" action="mail.php?act=contact">
and then it goes to mail.php?act=contact
but i'd like to do that without POSTING anything..
I've find this Tutorial
http://www.freewebmasterhelp.com/tutorials/php/6
its looks like exactly what I want to do..but I make out anthing..
$variablename=$_POST['variable'];
$variablename=$_GET['variable'];
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I don't quite understand what you are asking... you want to link to mail.php with the url variables that'd be used via that form?
mail.php?act=contact&username=Steve&email=steve@foo.com
mail.php?act=contact&username=Steve&email=steve@foo.com
I wanna create a single page..index.php
that from there..people would be able to visit other sections of the site..f.x
index.php=profilio
without going to profilio.php..
I want the entire site to go through index.php..
if you'll please help me doing one page..I don't think i'll be hard doing the rest..

that from there..people would be able to visit other sections of the site..f.x
index.php=profilio
without going to profilio.php..
I want the entire site to go through index.php..
if you'll please help me doing one page..I don't think i'll be hard doing the rest..
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
create a list of known, safe files you'll allow referencing to.. and match the input to it, then include the file.
Code: Select all
$knownFiles = array('contact'=>'contact.php', 'portfolio'=>'portfolio.php', 'default'=>'default.php');
$inc = (isset($_SERVERї'QUERY_STRING']) && !empty(trim($_SERVERї'QUERY_STRING'])) ? trim($_SERVERї'QUERY_STRING']) : '');
if(!isset($knownFilesї$inc])) $inc = 'default';
include($knownFilesї$inc]);is this script supposed to be inside the index.php/default.php
so it should be
<?php
then the code
and end with ?>
I get the whole $knownFiles = array('contact'=>'contact.php', 'portfolio'=>'portfolio.php', 'default'=>'default.php'); thing..I just don't get where to put it..
Thank alot..
& sorry for the newb question
so it should be
<?php
then the code
and end with ?>
I get the whole $knownFiles = array('contact'=>'contact.php', 'portfolio'=>'portfolio.php', 'default'=>'default.php'); thing..I just don't get where to put it..
Thank alot..
& sorry for the newb question
i'm getting this error:
Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in F:\Webspace\disk20\oktober.co.il\oktober.co.il\www\rafi\test\new\test.php on line 5
here's the phpinfo incase you need it..
http://www.oktober.co.il/rafi/test/info.php
and that's the code inside the tags..I've prodably messed something up 
once it works it should be test.php=contact ..right..
http://oktober.co.il/rafi/test/new/test.php
Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in F:\Webspace\disk20\oktober.co.il\oktober.co.il\www\rafi\test\new\test.php on line 5
here's the phpinfo incase you need it..
http://www.oktober.co.il/rafi/test/info.php
Code: Select all
<?php
$knownFiles = array('contact'=>'contact.php', 'portfolio'=>'portfolio.php', 'default'=>'default.php');
$inc = (isset($_SERVERї'QUERY_STRING']) && !empty(trim($_SERVERї'QUERY_STRING'])) ? trim($_SERVERї'QUERY_STRING']) : '');
if(!isset($knownFilesї$inc])) $inc = 'default';
include($knownFilesї$inc]);
?>once it works it should be test.php=contact ..right..
http://oktober.co.il/rafi/test/new/test.php
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
as always.. the code was untested...
works..
Code: Select all
<?php
$knownFiles = array('contact'=>'contact.php', 'portfolio'=>'portfolio.php', 'default'=>'default.php');
$inc = (!empty($_SERVERї'QUERY_STRING']) ? trim($_SERVERї'QUERY_STRING']) : '');
if(!isset($knownFilesї$inc])) $inc = 'default';
include($knownFilesї$inc]);
?>