I am working with some anchor tags in HTML where i need to carry over some arguments from the first url to the second url
My Link
My current URL is - oldpage.html?arg=value
But the "My Link" redirects to -
newpage.html
and not
newpage.html?arg=value
How do i carry over the value of arg ?
If you want to just copy a known variable over, it's as simple as
<?php echo "My Link" ?>
and then oldpage.html?arg=value would produce a link to newpage.html?arg=value.
However, if you want to pass over the entire query string, you can achieve this with the $_SERVER["QUERY_STRING"] variable.
<?php echo "My Link" ?>
This will propagate the entire query string to the new page. So if you accessed the current page with oldpage.html?arg=value&color=green, the link would point to newpage.html?arg=value&color=green.
Alternatively you could use http_build_query, allowing you to add extra parameters or modify the existing query string as you see fit.
<?php echo "My Link" ?>
Using this, navigating to the current page as oldpage.html?arg=value would produce a link to newpage.html?arg=value&foo=bar.
My Link
Or you could do this:
My Link
But that is only if your server allows you to use SERVER variables.
Related
how can I pass a parameter in a URL to a link on the page. So we have this link setup for all visitors from Facebook.
http://www.domain.com/event?source=facebook
We need to pass the source to the end of a link on the page which leads to a booking engine and registers as a conversion so that
http://www.bookingengine.com/tickets/1234/?ticket=567&event=8910
becomes
http://www.bookingengine.com/tickets/1234/?ticket=567&event=8910&source=facebook
Use <?php echo get_permalink($post_ID)."&source=".$yoursource;?> as your link, or something to that effect.
How do I remove special characters in URL codeigniter. I really confuse why this codeigniter getting the "#" or other ('Special Characters) in href and putting it in URL.
for example:
Company
<a href='company'> Add company </a>
URL shows:
localhost/app/home/#company
Any help? thanks
Load your helper url. Like this $this->load->helper('url');
then use
url_title()
Takes a string as input and creates a human-friendly URL string. This
is useful if, for example, you have a blog in which you'd like to use
the title of your entries in the URL.
Example:
$title = "What's wrong with CSS?";
$url_title = url_title($title);
// Produces: Whats-wrong-with-CSS
# is called hash.
You click on 1 link, the hash adds to your url.
You click on 2 link, it tries to go to url#company, browser will recognize anything after # symbol as hash.
Try to avoid this by putting onClick() javascript event on button and returning false.
The change you need to make is in the company url.
Add company
The # in a url identifies a fragment within a document.
I created a function that requires one parameter to be passed into it but I need that parameter to come from another script. How do I embed the variable into a link then put that variable into the function in another script? I know I need to utilize $_GET, isset($_GET['']) and a href but I just can't put it all together.
$_GET is collection of of query string parameters. If you had a url like: test.php?param1=foo¶m2=bar you can access foo by $_GET['param1'] etc..
Use $_REQUEST['something']
Your link must be:
Click Me
Inside test.php
if(#$_REQUEST['something']=="something"){
echo $_REQUEST['something1'];
}
When you click Click Me, test.php would echo "test".
I'm looking to pass a keyword from a HTML page to a PHP page through the URL string.
See example below to what I'm saying:
mysite.com/index.html?keyword=Google
the "Keyword" is Google and it needs to go over to my Thank you page.
mysite.com/thankyou.php
the code I use on my "thankyou" page is:
<?php $id = $_GET['keyword']; echo $id;?>
NOTE: I've visited and tried the links I found on the stackflow site... but none of them seem to work (asleast from what I've done with them). Am I missing any other thing when it comes to the code?
How do I get the current URL and then get the last words
how can i get the url if it is like this <keyword>?
How to pass a keyword from URL but keep it hidden? (Adwords)
If you could PLEASE provide a functioning example on a http://jsfiddle.net page so I can see how it works.
You need to have the get variable on the php page url, not the index.html page.
Example:
mysite.com/thankyou.php?keyword=Google
Alternatively you could write a html <form> and make a <input type="hidden" name="keyword" value="Google"> and grab it from POST instead of GET with PHP.
<?php $id = $_POST['keyword']; ?>
I'm trying to pass a complex URL as a url parameter but the problem occurs if the url contains & for example I want to pass the following link as a parameter
http://www.google.ps/search?hl=en&client=firefox-a&hs=42F&rls=org.mozilla%3Aen-US%3Aofficial&q=The+type+%27Microsoft.Practices.ObjectBuilder.Locator%27+is+defined+in+an+assembly+that+is+not+referenced.+You+must+add+a+reference+to+assembly+&aq=f&aqi=&aql=&oq=
I'm trying to get a URL as a parameter from a user and redirect user to this URL.
How could I handle this in PHP?
The whole Story:
I'm trying to make some ads analytics on flash files so user submit flash ads to a website which contains a link to the required webpage.
Now,my client needs to know how many times this flash file was clicked.To solve this I 'll till every one who submits flash to write a link to my client webpage and pass the required URL as a parameter as follows
http://myclientwebpage.com/disp.php?link=www.google.com&id=16
by this way I can update my database and get a count for how many times this link was clicked
Use urlencode() or rawurlencode().
You wrote:
I'm trying to get a URL as a parameter
from a user and redirect user to this
URL.
But you didn't answer the question - how do you get that URL? How does user provide you with it? Is it written in <input type='text'/>? Or does user click some link that contains URL as one of parameters? Or is passed as ID of some URL that is stored in DB?
One case that comes into my mind - replacing URLs in plain text and sending user to some "redirecting page" before opening real page, so final page does not see HTTP referrer which might contain some secure data (e.g., session ID). In this case, you would write
<a href='redirect.php?link=<?php echo rawurlencode($url); ?>'>
<?php echo htmlspecialchars($url); ?>
</a>
instead of
<a href='redirect.php?link=<?php echo $url; ?>'>
<?php echo htmlspecialchars($url); ?>
</a>
From what I understand, you'll need to replace & into &.
$url = str_replace('&', '&', $url);
& is reserved, used for separating GET parameters, & is for writing a literal ampersand in a URL.