PHP - $_get Variables In Include
I have this code:
Code: [Select] <?php $item_name = urlencode('product name'); $payment_amount = urlencode('20.00'); $payer_email = urlencode('me@email.com'); $getvars = "?item_name=$item_name&payment_amount=$payment_amount&payer_email=$payer_email"; include "http://www.mysite.com/ipn.php$getvars"; ?> It only seems to be passing $item_name, the other 2 variables come up as being set, but are empty. Similar TutorialsI have a file called myfile.html and it includes the following line: Code: [Select] <!--#include virtual="/output.php" --> The SSI statement works great, but I want more... I would like to be able to link to myfile.html?var=val and use the var string in the php file. However $_GET[var] equals nothing when I try this Is this not possible? I am building a member-based website, and I've got a bunch of buttons that lead from page to page. The links for these buttons are generated based on user ID and subsequent pages receive this variable as well. So, if you hover over the buttons, you get a link like this: http://www.mysite.com?id=423 How can I hide the last part? The '?id=423'? I must use this format of variable, and cannot resort to session variables. Is there a way to hide this portion of the links?? Hello, I just wanna know if any such commands are available in php for making a variable as such like - $variable = " blah blah .. . . . index.php?X=<?php echo $_GET['x']; ?>..........blah"; thank you Hi all. I have a question and don't know if it belongs in the PHP section or the Javascript section so I apologize in advance if I am in the wrong place. Basically what I am trying to do is change a URL with the following variables Code: [Select] index.php?id=16&?pid=23-P27-16&cid=1324353245 to something more secure....like Code: [Select] index.php I think doing it this way would add an extra layer of security to my website. If this is not possible, is there a way I can track whether or not a user attempted to edit something in the URL. For example, if the cid=13243543 and they go in a change it to 13243654 instead, can I have PHP check that? I have a great deal of security already, but I think this would truly be the highest layer, completely controlling what happens in the user's address bar. As always, thanks in advance! Bl4ck Maj1k I have a php search page that takes form data to create its queries, then reload the original search page. The form is long, so there are numerous $_POST's to convert to variables for use in the query. I've looked at "extract" and a few other code snippets. But it's a form and I don't want any security issues. I'm hoping there's a "foreach" solution, but I'm a beginner. What's a proper way to to simplify this: $s1 = $_POST["s1"]; $s2 = $_POST["s2"]; $s3 = $_POST["s3"]; $s4 = $_POST["s4"]; $s5 = $_POST["s5"]; $s6 = $_POST["s6"]; $s7 = $_POST["s7"]; $s8 = $_POST["s8"]; $s9 = $_POST["s9"]; $s10 = $_POST["s10"]; $s11 = $_POST["s11"]; $s12 = $_POST["s12"]; What i'm trying to do is have 20 HTML (href) links and a PHP include under the links. What I want is when a link is clicked the PHP include changes to a different file. Im sorry if its not very clear but i'm pretty new to PHP so don't know if its possible... Please can someone help Hey everyone, I'm new to PHP so excuse me if this is an obvious question: I've got a horizontal scrolling image gallery as an include, as it will be used in dozens of pages. Each page that includes the image gallery will be using different pictures and in different numbers (anywhere from 1 - 15 images). In each page that includes the image gallery, I've turned each image to be used into a variable.. $image 1 = "images/image1.jpg"; $image 2 = "images/image2.jpg"; ... $image 7 = "images/image7.jpg"; etc. Now, I imagine I need to write a loop in the include that will account for as many pictures as there are variables in each page, without adding links for variables that aren't in the page in question. Something like (simplified): Defined on page: $image 1 = "images/image1.jpg"; $image 2 = "images/image2.jpg"; $image 3 = "images/image3.jpg"; $image 4 = "images/image4.jpg"; Loop in photo gallery include: <?php for($i = 1; $i <=15; $i++) { $imagei = ("$" ."image".$i); if (defined($imagei)) { echo '<li><a href="' .$imagei.'">'; echo '<img src=" '.$imagei.'" >'; echo '</a></li>'; } } ?> I know this doesn't work because $imagei isn't referring to the defined variables on the external page, but I'm not sure exactly where to go from here. As in, $imagei in the first execution of the loop is equal to "$image1", but how do I link that to the $image1 variable defined in the page (as "image/image1.jpg") to display the image? Does that make sense? Thanks! Before, if I wanted to send a welcome letter when a user registers i'd do this. $body = "<inserted html code>"; mail('email@email.com', 'Subject', $body, $headers); Now that I am advancing in PHP, I was trying a different method, because when I did the above method, I would have to take all the HTML out of the variable to change something, like an image link, etc... I have tried doing another method, where I can actually leave all the HTML code in a separate file, so that I can easily edit it, and tried 3 things... This one works, but it doesn't pass variables: $body = file_get_contents("emailTemplate.inc.php"); mail('email@email.com', 'Subject', $body, $headers); When I do this one, the page actually just shows on the current page (naturally): $body = include("emailTemplate.inc.php"); mail('email@email.com', 'Subject', $body, $headers); Of course, this has the same effect as the include function: $body = require("emailTemplate.inc.php"); mail('email@email.com', 'Subject', $body, $headers); So my question is, how do I send a formatted HTML email, and pass variables to it, so I can personalize it by the persons name, etc, without adding the HTML to a variable, and so that I can easily update the page whenever I want, and without taking it out of the variable, and sticking back in the edited code? Any help would be appreciated! I would also like to say that I am using this code for the $headers variable too: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: from@email.com <email@email.com>' . "\r\n"; Thank you in advanced! I am having some real problems with the code in red below which sits in my "index.php" file, and would be very grateful for any help! <?php include("header.php"); include $_GET["view"] . ".php"; include("footer.php"); ?> The links for my "views" (e.g. <a href="?view=page_news">News</a> ) are in my "header.php" file. The whole website works absolutely fine, except when you first arrive on the homepage you get: Notice: Undefined index: view Warning: include(.php) [function.include]: failed to open stream: No such file or directory This is presumably because a link hasn't been clicked yet, thus a "view" hasn't been defined yet, but I have no idea how to get around this! I hope I haven't been too vague with my explanation... Thanks, James I am trying to pass a variable from inside of a function in a file that is included eg include.php Code: [Select] <? function noms(){ $foobar = "apples"; } ?> main.php Code: [Select] <? include("include.php"); noms(); echo "these ". $foobar. " are most delicious... OM NOM NOM"; ?> I am essentially using a include file for a mysql connection and based on the connection outcome i am either setting a value to true or false. It prints "Connected succesfully" and what not just fine, but, after that it wont pass on the variables data. I know its the function because, it passes the data if i put the variable before the function... i just dont get it.. any help would be great. Thanks. Ansel A few months ago, and a good amount of time before that, I had people telling me to use isset() instead of performing to see if the variable is empty, such as: !$_GET[''] I know the differences in the function and what they do, but when could isset() be used in a situation where it's better/more efficient then: !$_GET[''] I do use isset(), though. Hi Still a new comer when it comes to PHP. I have a situation where I want to use an include within an include and I am having trouble with my file paths. My main header include, includes everything for each page of my site, beyond the opening of the body to incorporate my navigation etc conditionally loading in css, and loading in titles and meta data etc depending on the page in question. This header needs to reference another include called the-pod.php which is required for every page, the only trouble is I want to use / to reference the root of the server and this is breaking my code. I can't use ../../ etc as its a different path depending on where the master file is located. So my question is how do I get around this? Can the root of the server or path to the root be stored in a variable? and if so how would I write this. Any tips / advice will be greatly appreciated. Hi Guys.. Merry Christmas Im kinda new to this fantastic world of PHP and i have a little problem i hope you can help me with. Im trying to build a website where I use include() to genereate my content. On my index.php i have a menu which includes content in a content div from external .php pages, my structure kinda goes like this.. (simplified) site/ index.php content/ fronpage.php products.php contact.php The HTML looks like this. <div id="menu"> <ul> <li><a href="index.php?page=frontpage">frontpage</a></li> <li><a href="index.php?page=products">frontpage</a></li> <li><a href="index.php?page=contact">frontpage</a></li> </ul> </div <div id="main"> <?php include('/content/'.$_GET['page'].'.php'); ?> </div> This all works very fine, but my problem is, can I have a include inside an already included page? I would like to have a menu on my products.php site, but that page is already included from above, and i would like the menu on the products.php site to stay as the content from the nested include changes with input from the /products folder. my idea was something like this. site/ index.php content/ frontpage.php products.php contact.php products/ product1.php product2.php the HTML on the index.php is the same as above and then i would add the include() on the products.php page, so its kinda the same thing, but one inside the other. HTML inside the products.php folder <div id="sub_menu"> <ul> <li><a href="#">frontpage</a></li> <li><a href="#">frontpage</a></li> <li><a href="#">frontpage</a></li> </ul> </div <div id="sub_main"> <?php include('/content/products'.$_GET['#'].'.php'); ?> </div> I dont know how to link to the new files so they will be included while the first include still stays on the page. Any of you know how and if this can be done? Or maybe at better way to do it? Hope this made sense, my first PHP question Thanks CanI put one INCLUDE statement INSIDE of another INCLUDE statement? does anyone know how to decode this XML variable value into string values? I also need to know the oposite way: creating variable values into xml. I've tried several code examples but they did filter the requested data. Code: [Select] $xml='<?xml version="1.0" encoding="utf-8"?> <elements> <text identifier="ed9cdd4c-ae8b-4ecb-bca7-e12a5153bc02"> <value/> </text> <textarea identifier="a77f06fc-1561-453c-a429-8dd05cdc29f5"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <textarea identifier="1a85a7a6-2aba-4480-925b-6b97d311ee6c"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <image identifier="ffcc1c50-8dbd-4115-b463-b43bdcd44a57"> <file><![CDATA[images/stories/red/cars/autobedrijf.png]]></file> <title/> <link/> <target/> <rel/> <lightbox_image/> <width><![CDATA[250]]></width> <height><![CDATA[187]]></height> </image> <text identifier="4339a108-f907-4661-9aab-d6f3f00e736e"> <value><![CDATA[Kramer 5]]></value> </text> <text identifier="ea0666d7-51e3-4e52-8617-25e3ad61f8b8"> <value><![CDATA[6000 RS]]></value> </text> <text identifier="90a18889-884b-4d53-a302-4e6e4595efa0"> <value><![CDATA[Eindhoven]]></value> </text> <text identifier="410d72e0-29b3-4a92-b7d7-f01e828b1586"> <value><![CDATA[APK Pick up and return]]></value> </text> <text identifier="45b86f23-e656-4a81-bb8f-84e5ea76f71f"> <value><![CDATA[15% korting op grote beurt]]></value> </text> <text identifier="3dbbe1c6-15d6-4375-9f2f-f0e7287e29f3"> <value><![CDATA[Gratis opslag zomerbanden]]></value> </text> <text identifier="2e878db0-605d-4d58-9806-8e75bced67a4"> <value><![CDATA[Gratis abonnement of grote beurt]]></value> </text> <text identifier="94e3e08f-e008-487b-9cbd-25d108a9705e"> <value/> </text> <text identifier="73e74b73-f509-4de7-91cf-e919d14bdb0b"> <value/> </text> <text identifier="b870164b-fe78-45b0-b840-8ebceb9b9cb6"> <value><![CDATA[040 123 45 67]]></value> </text> <text identifier="8a91aab2-7862-4a04-bd28-07f1ff4acce5"> <value/> </text> <email identifier="3f15b5e4-0dea-4114-a870-1106b85248de"> <value/> <text/> <subject/> <body/> </email> <link identifier="0b3d983e-b2fa-4728-afa0-a0b640fa34dc"> <value/> <text/> <target/> <custom_title/> <rel/> </link> <relateditems identifier="7056f1d2-5253-40b6-8efd-d289b10a8c69"/> <rating identifier="cf6dd846-5774-47aa-8ca7-c1623c06e130"> <votes><![CDATA[1]]></votes> <value><![CDATA[1.0000]]></value> </rating> <googlemaps identifier="160bd40a-3e0e-48de-b6cd-56cdcc9db892"> <location><![CDATA[50.895711,5.955427]]></location> </googlemaps> </elements>'; how do i get the id from the url so i can use it I am seen people have dynamic pages that loads the information from a database and then displays that information from the url. EG domain.com/somedirectory/something I have a website that does this but uses domain.com/something.php?id=something . This works great but when I go to try and get the statistics for that page from facebook for number of people that have liked that page. When I go to: http://graph.facebook.com/http://likebook.cz.cc/ It shows me the information: Code: [Select] { "id": "**************", "name": "LikeBook", "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs178.ash2/41817_130259343675613_3465_s.jpg", "link": "http://www.facebook.com/pages/LikeBook/130259343675613", "category": "Website", "description": "Collect every like at LikeBook.cz.cc", "fan_count": 3 } But when I try and go to: http://graph.facebook.com/http://likebook.cz.cc/like.php?id=31 It shows me: Code: [Select] { "id": "http://likebook.cz.cc/like.php" } So what I need to do is. Make a dynamic page within that sub directory. So that http://likebook.cz.cc/like/31 does grabs the information from line 31 of my database, like http://likebook.cz.cc/like.php?id=31 would do. Thank you ~AJ how would i get this to work if they have click on the add page and the action is add i want it to do something how would i do it Code: [Select] <?php if(isset($_GET['action'])){ } ?> <a href="pages.php?action=add">Add Page</a> I am a new programmer. I am working on a personal project for my portfolio, it is a simple blog. I am trying to give the user the ability to delete a blog entry. It works fine, the problem is that when you refresh the page, with out clicking 'delete' the entry is still deleted. $_GET is passing the $id to my function and it is executing. The code I have posted is my effort to fix the problem. How can I connect $_GET to the delete button ? I have tried using a hidden value but this is not working. Any help would be greatly appreciated. AL Code: [Select] // code to display message before deletion if($_GET['T']) { echo("<div style='float:right; width:25%; height:100px; position:absolute; top:150px; right:15%;'>"); echo("<h2>Are you sure you want to delete:<h2>"); echo $_GET['T']; echo("<form method='get' action='?'>"); echo("<input type='submit' name='button' value='Delete'>"); echo("<input type='hidden' name='submit_check' value='1'>"); echo("</form>"); echo("<form action='http://nuke.industry.com/Blogspiracy/UserPage/index.php'>"); echo("<input type='submit' value='Cancel'/>"); echo("</form>"); echo("</div>"); } // code to delete a selected blog entry function delete_blog($id) { global $dbh; $sql = "DELETE FROM tblBlog WHERE tblBlog.id = '$id' LIMIT 1;"; $sth = $dbh->prepare($sql); $sth-> execute(); return; } if (isset($_GET['id']) && ($_GET['submit_check'])) how do I "GET" the hidden value? { $remove = delete_blog($_GET['id']); } [code] How to find the name value using php or $_GET here is the url header("Location:http://localhost:8666/OnlineBookingsPhp/index.php?name=Next"); Thanks |