How to change the URL without change the page in php? - php

I have this URL when I click on a link that redirect me in 'domaine.php/subject1' :
www.mywebsite.com/domaine.php/subject1
I want to display an URL like this when I want to see an other subject:
www.mywebsite.com/domaine.php/subject2
But when I click on the link 'domaine.php/subject2' in the same page (page:domaine.php), it display:
www.mywebsite.com/domaine.php/domaine.php/subject2
What can I do to fix it?
Thanks in advance!

Related

How can I generate referral link without login interface in PHP?

so it goes like this :
Textfield "what is your name" and a submit button.
Output eg : so your name is ralph!
I want to add a link generator after clicking submit button which will be redirected to the main domain(mysite.com)
so the output will be :
So your name is ralph! here is your Link : domain.com/AbCd123
domain.com/AbCd123 will be redirected to domain.com
anyone knows how to do it?
Try to use the $_GET["VariableName"] from the url of the webpage where you want to process the "name", so, the link, could be something like:
http://www.domain.com/index.php?reference=ralph
In the index.php you can retrieve this value, from the $_GET["reference"] variable.

Codeigniter url gets appended every click

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/';

How to make a window pop up from a link using javascript

I am making a bookmarklet for my url shortener. What it does is it shortens the current url of a page when you click on the bookmarklet, so you don't have to go to a site to shorten a url, but what I need is for the bookmarklet to return a pop-up window with the shortened url listed below.
What I've done so far is this:
javascript:u=encodeURIComponent(location.href);s='http://n1x.co.uk/create.php?url='+u;window.open(s,'shortened','location=no,width=400,height=300');
If you have bookmarked this, you will notice when you click on it, it does shorten the url of the current page, but it also shows the url shortener webpage, and what I only need is plain text and a link to copy it.
Please help!
Edit: Sorry I'm that bad at php, but how can I make a parameter "responseType"? Thanks
What is shown in the popup is what is returned by http://n1x.co.uk/create.php. You will have to modify the php to return only the shortened url in plain text. If the php is being used by the shortener site also, what you can do is pass a parameter to create.php that tells it whether to return the whole page like it does now or to return only the plain text url. For example a parameter called 'responseType'. You can modify the create.php to say that when responseType = 'plainurl', return simply the shortened url and not the whole page.
javascript:u=encodeURIComponent(location.href);s='http://n1x.co.uk/create.php?url='+u + '&responseType=plainurl';window.open(s,'shortened','location=no,width=400,height=300');

how to change pagenav first number to linked to the orginal url of the page thread or post

hi i need help i have page navigation
look like this in the page navigation in vbuilletin 4.1.1:
First Previous ,1 , 2, Next Last
when i click the page 2 the url shows like that :
http://localhost/vbs/forumdisplay.php?f=2&page=2&order=desc
and that is fine with me but what i want is when i click
back to the page number 1 or click the "first" button
i don't want it to show the url like this :
http://localhost/vbs/forumdisplay.php?f=1&page=2&order=desc
what i want is to show the original url of
the first page for the thread or the post like this
http://localhost/vbs/forumdisplay.php?f=2
i tried to modify the pagenave template but with no success
plz can anyone advice me what i can do ??
if((int)$_GET['f']<2){
header('Location: http://localhost/vbs/forumdisplay.php?f=2');
die();
}
put this on top of the page... before any html output.

Making Browser Auto-Scroll to Most Recently Submitted Comment

I made a comment on a Wordpress blog and I noticed that after I submitted the comment, the top of the browser was flush with the top of my comment. In other words, the web page was auto-scrolled down to the top of my comment.
How can I do this? I am using a comment system with PHP / MySQL.
Thanks in advance,
John
Use an anchor and try to redirect adding the anchor to your link.
header('Location: http://www.example.com/questions/2301455#comment-54564');
should work.
Else you can do it with javascript by setting the hash property of the location object.
location.hash = '#comment-54564';
or using jQuery :
$(location).attr('hash', '#comment-54564');
You can use the following:
<a name="latest_comment">Comment goes here</a>
And then after a user posts a comment, redirect them to:
http://www.your-domain.com/your-uri#latest_comment
Check out this link under the "name attribute" section:
http://www.w3schools.com/html/html_links.asp

Categories