473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

include a file with parameters

What i want to do is the following:

include (pagecalled.php?argument1=x&argument2=x ..... );

(I need to place the page somewhere inside another one, as if it had
been called from another link)

Doesn't work this way, but it works providing full path

include 'www.somesite.com/dir1/dir2/pagecalled.php?argument1=x&argument2=x';

As you can see, it would be better without full path, in order to be
able to change server without code rewrite.

Is there any way to solve that situation?

sdos - jm
Jul 27 '05 #1
4 18648
julian maisano wrote:
What i want to do is the following:

include (pagecalled.php?argument1=x&argument2=x ..... );


How about this:

$argument1 = x;
$argument2 = x;
include('pagecalled.php');

--
http://www.phpforums.nl
Jul 27 '05 #2


Peter van Schie wrote:
julian maisano wrote:
What i want to do is the following:

include (pagecalled.php?argument1=x&argument2=x ..... );


How about this:

$argument1 = x;
$argument2 = x;
include('pagecalled.php');

--
http://www.phpforums.nl

Will pagecalled.php "see" both $argument1 and $argument2? How?
If so, why do we use this way: pagecalled.php?argument1=x&argument2=x?
Is it just an option to do the same?
regards - julian

Jul 27 '05 #3
julian_m wrote:
Will pagecalled.php "see" both $argument1 and $argument2? How?
Yes, because include() basically just inserts the code from
pagecalled.php at the position of the include call. Therefore the
$argument1 and $argument2 variables are available to the code in
pagecalled.php if you set them like this.
If so, why do we use this way: pagecalled.php?argument1=x&argument2=x?
Is it just an option to do the same?


No, it's not the same. You're talking about the HTTP GET method to send
data to a script from a html form, for instance data a user submitted
using a html form.

In your case you just want to be able to use php variables in a php
script you include from another php script.

--
http://www.phpforums.nl
Jul 27 '05 #4
> > > What i want to do is the following:

include (pagecalled.php?argument1=x&argument2=x ..... );


How about this:

$argument1 = x;
$argument2 = x;
include('pagecalled.php');

--
http://www.phpforums.nl

Will pagecalled.php "see" both $argument1 and $argument2? How?
If so, why do we use this way: pagecalled.php?argument1=x&argument2=x?
Is it just an option to do the same?


It will 'see' the variables the same way any code written after those
variables were declared could see them - a PHP 'include('');' takes the file
and mixes it in, almost like a copy and paste job of the file contents. Give
it a go, you'll notice it works.

Appending variables onto the URL is a method of sending variables across
pages, it is called 'GET' and another method is called 'POST' - have a read
at php.net.

To demonstrate GET, try this code by itself:

<?php echo $_GET['arg']; ?>

Now view the webpage and append ?arg=hello onto the end of the URL. You can
change arg to equal anything and it will display on the page.

Usually you wouldn't use GET unless you needed to, because the whole world
can see your variables in the address bar, and therefor can reassign them by
editing the URL. This opens your PHP script up to manipulation. However GET
is still pretty handy for times when you want to send variables to another
page through, say, a link, since POST only works through an HTML form. A
whole row of links like <a href=nextpage.php?arg=hello>Say Hello</a> but
with different values for 'arg' - you've only made 1 PHP file called
nextpage.php, but if it's recieving a $_GET['arg'] value you've got an
almost limitless amount of different permutations for that page (dynamic).

Luke



Jul 27 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: middletree | last post by:
I have a page which, according to the boss's instructions, needs to show one of two things, based on which radio button was chosen on the previous page. Because these 'things' are actually some...
7
by: Vojma | last post by:
I have a problem At my site I have designed a framework with tabs as below (tabs_1.asp) +----+ +------+ +-------+ | MC | | Cars | | Boats | + +------------------------- then, into...
9
by: JR | last post by:
Hi, I'm migrating my website to an IIS 6.0 server and all the asp pages work fine except for the ones that reference include files, even though I have "Enable parent paths" enabled in the...
6
by: qaz | last post by:
I run a web site on both a testing server and a "production" server. I noticed that references to the include file do not work on the testing server but they do work on the production server. I...
9
by: Sarath | last post by:
I am working with an application using ASP, getting below error when i am trying to include new asp include file. _____________________________________________________________________ Microsoft...
10
by: Toke H?iland-J?rgensen | last post by:
Hello. I am quite new to the c++ language, and am still trying to learn it. I recently discovered how using include files would allow me to split up my code into smaller segments, instead of having...
8
by: MVM | last post by:
I am new to VS 2003. I did programming in vb6 and vc6, but not through studio. I am having lot of confusion on how to start, where to start? I like to write a program in vc++ under vs 2003. i...
1
by: Greg Scharlemann | last post by:
There is probably an easy solution to this that I've overlooked somewhere... I have a main file, call it main.php, and an include file, myInclude.php. I'm accessing main.php via:...
10
by: vunet.us | last post by:
What is the workaround of passign a parameter to any included asp file: <!-- #Include File="file.asp" --> This obviously does not work: <!-- #Include File="file.asp?id=123" --> Thank you
14
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.