Page 1 of 1
hide link help on php
Posted: Sun Feb 28, 2010 1:40 am
by bonty89
Guyz I wanna know how to add like this on link (php)
eg:
http://www.websitename.net/index.php?mode=register
can any1 help pls ... thanks

Re: hide link help on php
Posted: Sun Feb 28, 2010 10:20 am
by davex
Sorry - not quite sure what you mean?
Do you mean you want a popup "hint" to come up when a user mouses over a link?
Code: Select all
<A HREF="http://www.somesite.com/" TITLE="Popup Text Goes Here">Here is the link</A>
Cheers,
Dave.
Re: hide link help on php
Posted: Mon Mar 01, 2010 6:24 am
by bonty89
I wanna know how set variable on the Index.php file
eg: when user click to login
it should display like this
http://www.anywebsite.org/index.php?action=login
similar to this forum login link
ucp.php?mode=login
register
ucp.php?mode=register
how to write like that
Re: hide link help on php
Posted: Mon Mar 01, 2010 6:44 am
by davex
Hi,
Oh - ok.
Well you do it exactly like that!
For example:
Code: Select all
<A HREF="login.php?first=1&second=2">Click Here</A>
Would call the PHP file login.php with two variables: $_REQUEST['first'] equal to 1 and $_REQUEST['second'] equal to 2.
This is known as the
query string - everything contained after the ?. I would suggest you have a read through one of the many excellent PHP tutorials either on a site like this or on
http://www.php.net.
But just to give you a very quick example of how this would work - imagine the following script called index.php:
Code: Select all
<?php
if (isset($_REQUEST['name'])) echo "Hello ".$name."<br /><br />";
?>
<A HREF="index.php?name=bonty89">Click here to set the name to bonty89</A><br /><br />
<FORM ACTION="index.php" METHOD="GET">
Name: <INPUT TYPE="TEXT" NAME="name"> <INPUT TYPE="submit" VALUE="Or Enter a Name and Click Here">
</FORM>
This will set the name either by clicking a link or entering in a form and then say hello to that name.
I would strongly recommend you work through some of the tutorials before developing though as this will allow you to learn how to deal the language and variables etc in a good way and avoid any future pitfalls.
Regards,
Dave.
Re: hide link help on php
Posted: Mon Mar 01, 2010 11:07 am
by bonty89
davex wrote:Hi,
Oh - ok.
Well you do it exactly like that!
For example:
Code: Select all
<A HREF="login.php?first=1&second=2">Click Here</A>
Would call the PHP file login.php with two variables: $_REQUEST['first'] equal to 1 and $_REQUEST['second'] equal to 2.
This is known as the
query string - everything contained after the ?. I would suggest you have a read through one of the many excellent PHP tutorials either on a site like this or on
http://www.php.net.
But just to give you a very quick example of how this would work - imagine the following script called index.php:
Code: Select all
<?php
if (isset($_REQUEST['name'])) echo "Hello ".$name."<br /><br />";
?>
<A HREF="index.php?name=bonty89">Click here to set the name to bonty89</A><br /><br />
<FORM ACTION="index.php" METHOD="GET">
Name: <INPUT TYPE="TEXT" NAME="name"> <INPUT TYPE="submit" VALUE="Or Enter a Name and Click Here">
</FORM>
This will set the name either by clicking a link or entering in a form and then say hello to that name.
I would strongly recommend you work through some of the tutorials before developing though as this will allow you to learn how to deal the language and variables etc in a good way and avoid any future pitfalls.
Regards,
Dave.
thanks
but my requirement is
eg:
<A HREF="index.php?name=bonty89">Click here to set the name to bonty89</A><br /><br /> it should display bonty89 html page or php page
eg2: <A HREF="index.php?name=bontyhelp">help Click here to set the name to bonty89 help</A><br /><br /> it should display bontyhelp html page or php page
how to set or write like that ???
see this site
http://www.dushyanth.com/
all the links starting from index.php? action=
but loading different pages
need help
thanks
Re: hide link help on php
Posted: Mon Mar 01, 2010 11:57 am
by davex
Ok...
First a full disclaimer - allowing files to be opened and executed from a variable is a potential big security hole. You should take very special care that you are only opening the files that you want. In the example below I am using an array to avoid manual file/path overloading but even so make sure everything is sanitised which the example below isn't!
Assume you have a directory called "modules" in there you have two files:
one.php
two.php
Then in your main directory you have an index.php like:
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if ( (isset($_POST['module'])) // if the module variable is present
{
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
}
?>
Hope that is what you are after.
Regards,
Dave.
Re: hide link help on php
Posted: Fri Mar 05, 2010 12:17 pm
by bonty89
davex wrote:Ok...
First a full disclaimer - allowing files to be opened and executed from a variable is a potential big security hole. You should take very special care that you are only opening the files that you want. In the example below I am using an array to avoid manual file/path overloading but even so make sure everything is sanitised which the example below isn't!
Assume you have a directory called "modules" in there you have two files:
one.php
two.php
Then in your main directory you have an index.php like:
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if ( (isset($_POST['module'])) // if the module variable is present
{
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
}
?>
Hope that is what you are after.
Regards,
Dave.
thanx but
Parse error: syntax error, unexpected T_VARIABLE on line 5
Parse error: syntax error, unexpected '{' in on line 10
Re: hide link help on php
Posted: Fri Mar 05, 2010 12:26 pm
by davex
Sorry typo:
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if (isset($_POST['module'])) // if the module variable is present
{
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
}
?>
Re: hide link help on php
Posted: Fri Mar 05, 2010 12:31 pm
by bonty89
davex wrote:Sorry typo:
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if (isset($_POST['module'])) // if the module variable is present
{
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
}
?>
still Parse error: syntax error, unexpected '{' in on line 10
Re: hide link help on php
Posted: Fri Mar 05, 2010 12:41 pm
by davex
Sorry but parses fine for me.
Haven't copied any newlines in by accident? Comments appear on the same line as code.
The typo was an extra ( on line 9 but my update and your quote don't have that.
Not sure what is causing it.
Cheers,
Dave.
Re: hide link help on php
Posted: Fri Mar 05, 2010 11:14 pm
by bonty89
bonty89 wrote:davex wrote:Sorry typo:
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if (isset($_POST['module'])) // if the module variable is present
{
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
}
?>
still Parse error: syntax error, unexpected '{' in on line 10
Parse error: syntax error, unexpected T_VARIABLE in line 05
but
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
?>
works
but links not working
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
both the links redirecting to index.php

Re: hide link help on php
Posted: Fri Mar 05, 2010 11:37 pm
by bonty89
bonty89 wrote:bonty89 wrote:davex wrote:Sorry typo:
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if (isset($_POST['module'])) // if the module variable is present
{
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
}
?>
still Parse error: syntax error, unexpected '{' in on line 10
Parse error: syntax error, unexpected T_VARIABLE in line 05
but
Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
?>
works
but links not working
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
both the links redirecting to index.php

Code: Select all
<HTML><BODY>
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
<?php
$modules = array(
"one" => "one.php",
"two" => "two.php" );
if (isset($_POST['module'])) // if the module variable is present
{
if (isset($modules[$_POST['module']])) // if the module is listed in the array
{
include_once "modules/".$modules[$_POST['module']];
}
else // illegal module not in array
{
echo "Illegal Module Specified!";
}
}
?>
[/quote]
but
works
but links not working
<A HREF="index.php?module=one">Module One</A> | <A HREF="index.php?module=two">Module Two</A>
<HR><BR />
both the links redirecting to index.php

Re: hide link help on php
Posted: Sat Mar 06, 2010 1:53 am
by davex
Hi,
Have you created the module files in the module directory?
The page will still be index.php but the different module pages will be displayed as in the example you originally gave.
Cheers,
Dave.
Re: hide link help on php
Posted: Sat Mar 06, 2010 10:36 am
by bonty89
davex wrote:Hi,
Have you created the module files in the module directory?
The page will still be index.php but the different module pages will be displayed as in the example you originally gave.
Cheers,
Dave.
assume that we running from the root
what will be the code !!! thanks
Re: hide link help on php
Posted: Sat Mar 06, 2010 11:11 am
by davex
From my post above:
Ok...
First a full disclaimer - allowing files to be opened and executed from a variable is a potential big security hole. You should take very special care that you are only opening the files that you want. In the example below I am using an array to avoid manual file/path overloading but even so make sure everything is sanitised which the example below isn't!
Assume you have a directory called "modules" in there you have two files:
one.php
two.php
Create a directory called modules and put in it files one.php and two.php - they will be included when selected.
Cheers,
Dave.