tom.hill Posted February 5, 2008 Share Posted February 5, 2008 Hi guys, im a bit stuck, im trying to include a variable within an include statement so that the page that is included depends on a variable if you get my drift! this is what i have got so far but its not working, all im getting is a blank page :S <?php // Check if session is not registered , redirect back to login page. include('includes/checklogin.php'); // Connect to server and select database include('includes/db_login.php'); // keyid sent in url $keyid = $_GET['keyid']; $query = "SELECT * FROM tkeys WHERE keyid = '$keyid' AND isdeleted = '0'"; $result = mysql_query($query); if ($result) { $row = mysql_fetch_array($result, MYSQL_ASSOC); $softwareid = $row["softwareid"]; } else { die ("Could not query the database: <br />". mysql_error()); } // Mark key as deleted $query = "UPDATE tkeys SET isdeleted = '1' WHERE keyid = '$keyid' AND isdeleted = '0' LIMIT 1"; $result = mysql_query($query); if($result) { $url = "viewlicences.php?softwareid=$softwareid"; include("$url"); } else { die ("Could not query the database: <br />". mysql_error()); } ?> can anyone spot any silly mistakes?? many thanks in advance. Tom Quote Link to comment Share on other sites More sharing options...
craygo Posted February 5, 2008 Share Posted February 5, 2008 I don't think you can include a page and use the parameters like you have. do you want to include the page or can you redirect to the page. If you want to include you can alway try setting the $_GET right on the page and then include the page. <?php if($result) { $_GET['softwareid'] = $softwareid; $url = "viewlicences.php"; include("$url"); } else { die ("Could not query the database: ". mysql_error()); } ?> Ray Quote Link to comment Share on other sites More sharing options...
tom.hill Posted February 6, 2008 Author Share Posted February 6, 2008 thanks for your reply Ray, im a little confused tho, surely that would send the user to viewlicences.php every time? without the variable being passed in the URL? (that is picked up by viewlicences.php and shows specific content dependent on the variable) i dont really mind how i work it include/redirect anything but i need php processing on that page first before the 'redirect' :S is this possible? Quote Link to comment Share on other sites More sharing options...
craygo Posted February 7, 2008 Share Posted February 7, 2008 Well no. Actually this will INCLUDE the page viewlicences.php. I'm sure somewhere on that page you are looking for the GET variable softwareid. So what I did was set the get variable then included the page so it will find it. If you wanted to redirect then you could use header('Location:http://yourwebpage/viewlicences.php?softwareid='.$softwareid.''); Ray Quote Link to comment Share on other sites More sharing options...
tom.hill Posted February 9, 2008 Author Share Posted February 9, 2008 thanks for your reply craygo, i wonder if it is possible to simply send the user back a page? if i could do this i wouldnt need any redirect code or variables, just sending the user straight back to where they came from would do the trick??.... Quote Link to comment Share on other sites More sharing options...
tom.hill Posted February 11, 2008 Author Share Posted February 11, 2008 I wonder if anyone can help if I try to explain myself a little better. I’m creating a system to store software licences and link them with hardware. At the moment the user can view hardware (computers, model numbers serial numbers etc) and then drill down to view the software licences that are installed on a specific computer, I have achieved this by passing the hardwareid variable to the viewhardware page and a table is created showing the results, the user can then choose to "uninstall" a software title from that hardware, this works as far as the database is concerned but I’m unable to return the user to the page they were viewing, instead I have to send them back to the main hardware page (that does not have a variable in the url) what I would like to achieve is to send the user back to the specific computer page that they were at before selecting to uninstall the software, but this requires a variable sent in the url. Am I going about this the wrong way?? Really stuck, as always many thanks in advance. Tom Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.