eg: http://www.websitename.net/index.php?mode=register
can any1 help pls ... thanks
Moderator: General Moderators
Code: Select all
<A HREF="http://www.somesite.com/" TITLE="Popup Text Goes Here">Here is the link</A>Code: Select all
<A HREF="login.php?first=1&second=2">Click Here</A>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>thanksdavex wrote:Hi,
Oh - ok.
Well you do it exactly like that!
For example:
Would call the PHP file login.php with two variables: $_REQUEST['first'] equal to 1 and $_REQUEST['second'] equal to 2.Code: Select all
<A HREF="login.php?first=1&second=2">Click Here</A>
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:
This will set the name either by clicking a link or entering in a form and then say hello to that name.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>
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.
Code: Select all
<h1>One</h1>Code: Select all
<h1>Two</h1>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!";
}
}
?>thanx butdavex 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.phptwo.phpCode: Select all
<h1>One</h1>Then in your main directory you have an index.php like:Code: Select all
<h1>Two</h1>
Hope that is what you are after.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!"; } } ?>
Regards,
Dave.
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 10davex 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!"; } } ?>
Parse error: syntax error, unexpected T_VARIABLE in line 05bonty89 wrote:still Parse error: syntax error, unexpected '{' in on line 10davex 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!"; } } ?>
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!";
}
?>bonty89 wrote:Parse error: syntax error, unexpected T_VARIABLE in line 05bonty89 wrote:still Parse error: syntax error, unexpected '{' in on line 10davex 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!"; } } ?>
but
worksCode: 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!"; } ?>
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!";
}
}
?>assume that we running from the rootdavex 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.
Create a directory called modules and put in it files one.php and two.php - they will be included when selected.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.phpCode: Select all
<h1>One</h1>
two.phpCode: Select all
<h1>Two</h1>