Can anyone tell me whats wrong with the following code: include("restaurantsignup.php?restaurantname=".$_POST[restaurantname].""); it says the page doesn't exist but if I do: include("restaurantsignup.php"); it works fine? EDIT: btw the $_POST variable shows up fine when echoed and the restautantname is a variable on the restaurant.php page.
Either way thats not working ... this is the error Warning: include(restaurantsignup.php?restaurantname=Mofiki's Indian) [function.include]: failed to open stream: No such file or directory in /home/regretthecurve/verify_restreg.php
variables don't pass through includes if you're including a file the variables will already be defined... not through POST though... if you defined $restaurant you can call the variable in $restaurantsignup.php
Yup. Variables can't be assigned inside include statement. You must pre-set the variable and global it inside the included php file. That's the only way. Cheers, Venetsian.
What you could do using the $_POST['restaurantname'] and set its value to a session. Declare the session into a variable in the include and then unset the session variable. ie: first page session_start(); $m = $_POST['restaurantname']; $_SESSION['restaurantname'] = $m; include("restaurantsignup.php"); PHP: restaurantsignup.php session_start(); $name = $_SESSION['restaurantname']; unset($_SESSION['restaurantname']); PHP:
100% correct. Furthermore, using the question mark (reg.php?var=value) makes sense for a browser only. It's the GET method of HTTP protocol.
Hah, yeah. Include works via the filesystem, not via HTTP get... you cannot pass data that way... Funny someone would even try (am I that far removed now?) Generally in my includes I use the security practice that no library file should ever output anything directly - which means everything in that include should be wrapped in a function... Which would be your solution and also mean you don't have to use globals. Likewise I tend to include them with require_once just to prevent accidental double-load. require_once('restaurantsignup.php'); restaurantsignup($_POST[restaurantname]); Code (markup): Of course, you shouldn't have to pass that particular value in the first place, since $_POST is already a superglobal... In any case that would take a rewrite of your restaurantsignup.php to work... Said rewrite being doing it the 'right way' instead of the 'half-assed way'. Since globals are the half-assed way. Of course, that you are handling superglobals without sanitizing