PHP - Remove Variables From Url
I am passing variable to a PHP page and was wondering if there is a way to clean these varilabes from the url once i pull the information out of it.
For example my URL is "http://www.MYURL.com/index.php?var1=TEST1&var2=TEST2" Now what i want to be able to do is when someone visits the above link i want to assign var1 and var2 to a variable and then remove then from the addressbar so the vistor can only see the base URL (http://www.MYURL.com) in the address bar but i get my variables Anyone know what i can use??? Similar TutorialsFirst problem fixed. My second problem is if the result is 0X.XX,0 or 0X.XX,1 I would like to remove the first 0 The X.XX are numbers, but the 0 is not always there. Can anyone help please Thanks 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>'; Hi. I have some code which needs to return a single variable from the function and stored as a variable within this page, so it can be echoed later on in the page. I couldn't get it to return as a variable, so i used "return compact();" to return the variable and "extract (myFunction());" to extract it to variables. However, when I turned on php's display errors and error reporting function, I got an error message saying "Warning: extract() [function.extract]: First argument should be an array in /my/web/site/index.php on line 6" (which is where my extract function is). This works fine with passing more than one variables through, is there another way pass one variable from a function to be stored as a variable on the page which called the function? Here is the function: Code: [Select] <?php //This is a list of numeric error codes against their text. this will return the error code as the variable $issue function checkLoginIssue() { //If there is an error code if (isset($_GET["issue"])) { //cycle through the list until the code is reached, return the text and break the switch switch ($_GET["issue"]) { case "1": $issue = '<p class="warning">Please log in to view this page</p>'; break; case "2": $issue = '<p class="warning">Wrong Username or Password</p>'; break; case "3": $issue = '<p class="warning">No user found with those details</p>'; break; } //return the variable in an array with a single value return compact('issue'); } } ?> And here is the code which calls the function: Code: [Select] <?php extract(checkLoginIssue()); ?> i need to make it so it removes the \ like this <iframe src=\"http://www.rockstargames.com/videos/embed/8001\" width=\"640\" height=\"360\" frameBorder=\"0\" scrolling=\"no\"></iframe> I'm a noob, tring to reverse engineer some current code. This code is grabbing the current URL: <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?> This form is adding "&limit=50" to the URL, to show 25, 50 or 100 results per page: Code: [Select] <form> <select name="link"> <option <? echo "$select25" ?> value="<? echo curPageURL(); ?>&limit=25">25 records per page</option> <option <? echo "$select50" ?> value="<? echo curPageURL(); ?>&limit=50">50 records per page</option> <option <? echo "$select100" ?> value="<? echo curPageURL(); ?>&limit=100">100 records per page</option> </select> </form> The problem is here (I think). This is supposed to flush the old limit before requesting a new one... but right now, I'm getting another one tacked on with each new request: www.website.com/members?sub[]=math&sub[]=science&lev[]=middleschool&limit=25 www.website.com/members?sub[]=math&sub[]=science&lev[]=middleschool&limit=25&limit=50 www.website.com/members?sub[]=math&sub[]=science&lev[]=middleschool&limit=25&limit=50&limit=100 <?php //remove any old limit from query $tmp = array(); foreach ($_GET as $fld => $val) if ($fld != 'limit') $tmp[] = $fld . '=' . $val; $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] . '?' . implode('&',$tmp); ?> Any ideas? Thanks. ~Wayne I need permanent redirect. Example url: example.com/something/more/more/1 I always have /something/, so it would be awsome if you could remove /1 only from urls where are /something/ for first path argument. There can be any number of different url segments in between /something/ and /1, those should be kept there, just /1 should be removed. So the redirect path of the example url should be example.com/something/more/more How can I do this? Hi guys, I need your help. I am using the code below to send email via using with php, however, I can't be able to remove the mailed-by hostname which is something like: server01.domain.com. Here's the screenshot: Here's the code: if(isset($name)) { $name = $_GET['name']; $headers = "From: "-f .$name."@myemail.com"; $to = "myname@myemail.com"; $subject = $type; $message = $comments . ' ' . $rate; $header = "From: Your Name <tester@email.org>\l\n"; $header .= "Reply-To: no answer <myname@myemail.com>\l\n"; $header .= "Return-Path: tester@email.org\l\n"; $header .= "Envelope-from: tester@email.org\l\n"; $header .= "MIME-Version: 1.0\l\n"; $header .= "Content-Type: text/html\l\n"; mail($to, "test", "hello,how r u today? I'm a Noobie", $header); echo "Thank you for sent us your feedback"; When I use the code on above, the mailed-by hostname did not get removed. I want to remove it so I can send email to my clients for update email newsletters, registering form...etc Anyone who know how to remove the mailed-by hostname would be much appreciate. Thanks, Mark This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=325974.0 hi phpfreaks I am trying to remove the get variables from my url. the code below works if I echo it out but to try to modify the $_server variable it will not work. Any ideas? Code: [Select] $current_url = explode('?',$_SERVER["REQUEST_URI"]); $_SERVER["REQUEST_URI"]= $current_url[0]; echo $current_url[0]."<br>"; Anyone know how i can remove a querystring from url. Example URL: http://www.mysite.com/?id=1 I am writing a script that needs to read in the ID from the URL. But once have got the information i would like to remove it from the URL and just display http://www.mysite.com but still be able to use the ID to query my database. Any ideas??? Not sure if this is possible. What I am trying to do is remove a section of text a user posts. ie: go to this url: http://url.com or http://this.domain.org I already have it to strip they <a href="whatever but not sure if I can do the other. Any help would be appreciated. Thanks This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=328353.0 Hi All, I'm sure there is an easy solution for this but I am unable to find it. I am new to PHP and after a little help... the via data is stored in a database in this format... |51.105166,-1.695971|51.011055,-2.1068|50.945233,-2.617664|||| I'm trying to find a way of loosing the last comma if there are 1 or more entries, any ideas guys. What I'm getting is : Code: [Select] var points = [{location: '51.105166,-1.695971'},{location: '51.105166,-1.695971'},]; What I'm after is: Code: [Select] var points = [{location: '51.105166,-1.695971'},{location: '51.105166,-1.695971'}]; Code: [Select] <?php if($via != null){ echo "var points = ["; foreach($via as $point){ if($point != ""){ echo "{location:"; echo " '".$point."'"; echo "},"; } } echo "];\n"; } ?> Im trying to rermove ' symbol from a string. Code: [Select] $string2 = str_replace(" ' ", " . ", $string1); give errors How else could i do this? Please can someone advise how I remove the | characters from a string? I tried the following but get errors that... Warning: preg_replace() [function.preg-replace]: No ending delimiter '|' Code: [Select] $value = preg_replace("|", "", $value); My current code (which works): Code: [Select] <?php $body = explode("\n", $body); $body = array_slice($body, 3); $body = implode("\n", $body); ?> Is there a better way of doing this, so I dont have to explode and implode an array just to accomplish this? I'm currently have this code (part of code):
if (strlen($trimmed['title']) > 3 && strlen($trimmed['title']) < 200) { $title = mysqli_real_escape_string($dbc, $trimmed['title']); } else { echo '<div class="alert alert-danger" id="alerta3"> <button type="button" class="close" data-dismiss="alert">×</button> <center><p>Error</p></center> </div>'; $errors=true; } if (strlen($trimmed['description']) > 3 && strlen($trimmed['description']) < 4000) { $description = mysqli_real_escape_string($dbc, $trimmed['description']); } else { echo '<div class="alert alert-danger" id="alerta4"> <button type="button" class="close" data-dismiss="alert">×</button> <center><p>Error</p></center> </div>'; $errors=true; }What should i modify to avoid texts with /n/r? Thanks Hey, i got this code which takes info from mysql: while ($row= mysql_fetch_array($result)) { $title = $row["alertid"]; $title2 = $row["alerttext"]; $title3 = $row["alertdate"]; $bla = "{\"alertid\":\"$title\",\"alerttext\":\"$title2\",\"alertdate\":\"$title3\"},"; echo "$bla"; } it is displayed like this: [{"alertid":"1","alerttext":"text1","alertdate":"date1"},{"alertid":"2","alerttext":"text2","alertdate":"date2"},{"alertid":"3","alerttext":"text3","alertdate":"date3"},] I wanted to ask, how can I remove the last comma, after date3"}, but keep other commas..? This is probably very obvious but i gots stuck. I want to to display a list of the members then you select the member and it deletes the member. I do not get a message saying it failed, it just doesn't delete the member. Removemember.php: Code: [Select] <form action='removemember_complete.php' method='POST'> <label>Name:</label> <select name="memberid"> <?php $con = mysql_connect("localhost","slay2day_User","slay2day"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("slay2day_database",$con); $sqlquery="SELECT * FROM `members` Order By name"; $result=mysql_query($sqlquery,$con); while($row=mysql_fetch_array($result)) { echo "<option value='".$row['id']."'>".$row['name']."</option>"; } ?> </select> <br> <input type="submit" value="Remove" /> </form> removemember_complete.php: Code: [Select] <?php $name=$_POST['name']; $con = mysql_connect("localhost","slay2day_User","slay2day"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("slay2day_database",$con); $sql="DELETE FROM members WHERE name = '$name'"; if(mysql_query($sql,$con)) { echo 'Member Removed.<br /><a href="../index.php">Return To Points List</a><br /><a href="removemember.php">Remove More Members</a>'; } else { die('Could not submit: ' . mysql_error()); } mysql_close($con); ?> Thanks in advance. How do i remove with %20%20%20 from a pictures name? Silly question but my pictures wont show because of the %20%20%20 in the picturename. |