I have a PHP/HTML button who was link to
<? echo "Login"; ?>
Now I want change to other link to url www.button.com/index.html I changed the ine as :
<? echo "Login"; ?>
the second url is located on same server in other folder , but click on button not forward to link.
If you do not specify the protocol (e.g. http), the function assumes you want to go to a page on the same domain.
Try something like this:
<?="Login" ?>
Also, why are you using a JavaScript event? You could simplify this a lot by just putting the URL in the href attribute (href="//www.button.com").
Related
I'm trying to link to another page without displaying the real URL on hover or in the source code. I want <a> to redirect to $newUrl; even if there is another url defined in the href="".
<?php $newUrl = "http://therealurl.com/folder/private.php" ?>
Link
So using the code above I want to replace http://domain.com with <?php echo $newUrl; ?> when the user clicks on the <a> because i never want it to be displayed to the user.
Is there a solution to target a specific anchor to do this? If not then every link on the page is fine I just want to do this in a way that the real URL is not displayed for privacy reasons.
Here is solution.
<?php $newUrl = "http://therealurl.com/folder/private.php"; ?>
<script>
$( document ).ready(function(){
$( '#link' ).click(function(){
var newLink = <?php echo json_encode($newUrl);?>;
$(this).attr("href", newLink);
});
});
</script>
<a id="link" href="http://domain.com">Link</a>
Don't forget to include jquery library.
If you have full access to the original link, you could use it as a redirect by setting a header in the destination script.
header("Location: yoururl.php);
This is the only quick easy solution that I can think of, as this one will not show the actual destination in the source code.
If you want to hide the link from the source code then any javascript methods won't work, to my knowledge.
You could also use ?page=get stuff to change where it sends the user, in order to make this script usable in multiple ways, just don't forget to manage your GET data safely.
I have a problem with CI whenever i click a button in a form which has an action of image/upload or a hyperlink with the same link it gets appended whenever i click it the second time. say for example my home is localhost/admin and i click a button or a link which has image/upload.. so the url will now beh localhost/admin/image/upload but when i click the same button the second time the url will now beh calhost/admin/image/image/upload wchich well then cause a 404 error which ofcourse is the error given that the page is not found by just seeing that url. it gets appended every time i click the button or the link.
Anyone of you knows this please do share!
UPDATES:
BTW just a headsup for all those people who didn't know or who encountered this problem.. USE anchor or any helper in CI becuase if you manually put links in href or actions on form tag without putting the base_url.. your URL will be messed up.. helpers do append base_url. :D
Check out the Codeigniter docs and the URL Helper. That should help out.
http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html
I know for anchors you would just do:
echo anchor('image/upload', 'Upload');
This will append the url to the base url and you don't have to worry about changing anything or any 404 errors.
just put http:// at infront of your link.
or otherwise
change your config file:
$config['base_url'] = 'http://www.yourhost.com/home';
try to link the url as '/path-to-url'. notice '/' before url.
Link
currently you might be doing like below
Link
Also try changing
$config['base_url'] = 'http://localhost/home/';
I have a table in which there are small href links assigned in each row which i have set using below code working fine:
<h10>(check status)</h10>
Now I do not want to display the same above href link as static but want to send my variable value to the pop window and need to get data displayed separately for each row.
In short i want to pass my variable $name in the popup window. I am trying below code but but isn't happening. Even i tried <FORM> by GET
<?php echo "<h10>(check status)</h10>";?>
On popup.php page:
<?php echo $id = $_GET["id"]; ?>
What i want want is to pass variable using any method (GET or HREF), and it should open in new popup window not in next tab or forwarded window
change this
<?php echo "<h10>(check status)</h10>";?>
to
<?php echo "<a target='_blank' href='popup.php?id=".$name."' onclick=\"window.open(this.href, 'popupwindow', width=400,height=300,scrollbars,resizable');return false;\"><h10>(check status)</h10></a>";?>
^ ^ ^ ^// here was the mistake
You have not concatenated the strings properly and you missed ' for herf attribute.
Use target="_blank" for opening link in new tab or new browser.
does anyone know if i can get header in php to take a user to a certain point on a page when a form has been submitted and a function has finished and then it redirects a person back to a certain part of that page?
this is my if result:
$_SESSION['message_sent']="<div class=\"message_sent\"></div>";
header("Location: {$_SERVER['HTTP_REFERER']}");
it currently takes the user back to the page they was on but i want the user to be taken to the middle of the page?
thanks.
try doing as following, take for eg : "test" is the "name" attribute of anchor tag on the page :
HTML CODE :
<a name="test"></a>
<div>
.......
</div>
PHP CODE :
$path = $_SERVER['HTTP_REFERER']."#test";
header("Location:$path");
If you're familiar with having links within a page this should be simple.
You basically have your URL and append the id of the HTML element you want the page to go to when it loads. For example a URL like this:
http://www.mysite.com/index.php#about
Would take you to the following element on the index.php page:
<div id="about"></div>
I have a url1.
But I have seen on websites that they would use javascript to show this as url1 but it is actually url1 which redirects to url2.
You would not see the original url when you hover your mouse over the link.
The same thing is also used on google's search results. Can you please suggest how it is done. :)
You can use JavaScript onclick event to change the href on click.
Example: link
In this example users see that the link url is url1 but when they click on it goes to url2.
For a simple, example, you could make a redirect script that just takes the url out of a GET parameter, and then redirects the user to that page.
redirect.php:
<?php
$Link = $_GET['l'];
// Do whatever you want with $Link here (store it in a database, for example)
header('Location: ' . $Link);
?>
Now, instead of linking to url1, you can link to redirect.php?l=url1.
Please keep in mind that in an actual environment, you'd probably want to do some sanity checks on $Link before redirecting the user there.