Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Passing variables from page to page

Posted by enquirer (enquirer), 1 August 2002
I am using php and mysql on a Apache server in Linux. I have noticed in the book Php and Mysql, there is a "?" in certain spots that from what I gather is passing variables to the next page.  for example:

display_button("edit_category_form.php?catid=$catid", "edit-category", "Edit Category");

I am having trouble getting this to work and was wondering if this is a php setting or apache setting to enable the passing of variables to the next page.

Posted by admin (Graham Ellis), 1 August 2002
The "?"  within the URL indicates that the following information is to be passed into the PHP as a  variable through the GET method - if you look at the URLs (locations lines) associated with this forum, you'll find it uses the same technique.  The display_button function that you have in your sample code is not part of the standard PHP function set, so I can't comment on why it's not working.

As of release 4 of PHP,  session fucntions such as session_start and  session_register allow you to register variables to a session so that they're maintained for you from one page to the next.  These routines also keep the sessions of different users apart so that (for example) orders don't get mixed up.  "Maintenance of state" is a major subject - really beyond the scope of a  quick answer on a form, and if you would like to studey this further I would direct you towards a good tutorial - for example in a book - or a training course that covers it.

Just to get you started, here's some PHP code that registers a session and
starts to make use of it too ...

<?php
 // Session demo - shopping cart

 session_start();

 //////////////// Brand new session - offer login

 if (! session_is_registered("active")) {
     session_register("active");
     $active = 1;
     $heading = "Welcome - please log in";
     $htmlsay = "Please enter your name <input name=whoareyou>";

 } else {

 //////////////// Name has been entered - store it

   if (! session_is_registered("uname")) {
       session_register("uname","cart");
       $uname = $whoareyou;
       $cart = array();

 }



Posted by enquirer (enquirer), 2 August 2002
I have ran into the same syntax where the "?" comes right after php in the parameters of the function. I was just curious as to if  I needed to turn on something in the php ini file to get the variable passing to work or if I can use the $HTTP_POST_VARS or something equivalent to pass the variable to the next page as opposed to retrieving it from the previous page.

Posted by admin (Graham Ellis), 2 August 2002
The "?" straight after the URL (i.e. after the letters "php" in the case of a PHP page) signifies that the following information is to be sent on up to the server appended tot he URL - i.e. using the GET method, so it won't appear in the $HTTP_POST_VARS array - POST and GET are two different things.

In versions of PHP up to and including 4.1.x, the information afer the ? will appear in variables of the same name as the first word, content being the second word - for example
     .....php?fred=tom
will give you a variable called $fred with the value tom.

From versions 4.1.x up, you should use the $_GET array, so our example would set you an array element called $_GET["fred"] with a value of tom.  It is possible to change your php.ini file to still give you a variable with the same name as the field name on the form, but this is discouraged as it can lead to some weak security unless you're careful what you're doing!



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

Comment: "I have put in my page this: include ..."
Visitor Ranking 3.0 (5=excellent, 1=poor)

Comment by Monica M. (published 2010-08-04)
I have put in my page this: include "client_proiect.php?idpers=".$row['id_persoana'];
and I get this error: Warning: include(client_proiect.php?idpers=3) [function.include]: failed to open stream: No error in C:\wamp\www\linea-directa\indexx.php on line 34

Warning: include() [function.include]: Failed opening 'client_proiect.php?idpers=3' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\linea-directa\indexx.php on line 34

That can I do? That I do wrong?? [#3659]

You can Add a comment or ranking or edit your own comments

Average page ranking - 3.0

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho