Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Currently I have a search box on site.com/search.php. A user enters in a search term and is taken to site.com/index.php which displays the results for the search terms. Except, no matter what a user enters, the results page URL will always just be site.com/index.php - instead, I want it to read site.com/search=word1+word2 or something like that so that each page has a unique URL based on the search input.
I also want it to work in the reverse way, so that someone could, in theory, go straight to site.com/search=query and it would be the same thing as if they first went to the main search page, typed something in, and hit return.
I'm new to programming and recently started learning about the .htaccess file which I understand I'll need in order to do this. I am just at a total loss as to how to do what I want. I know I need some sort of URL re-writing but not much more than that.
The easiest approach here is to change your search form to use method="get" instead of method='post'.
This will create a URL like:
site.com/index.php?search=word1+word2...
Simply change the search script to use $_GET or $_REQUEST instead of $_POST and you'll be all set without any other significant changes. It will also let users directly run searches via the URL.
The only downside of this approach is that it does not create a beautiful URL (i.e. is still shows "index.php")... however, you can easily work around this by using .htaccess to rewrite the URL.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
My website's URLs are as:
"/movie.php?id=10 Rangoon (2017)"
Spaces are converted to %20 by web browser.
But I want the simple URL like this:
"/Rangoon-(2017)"
How Can I do that?
My website is developed in PHP and all data of my website is placed on MySql Database and "movie.php" page retrieves the data from MySql Database.
Well, that's not a simple one, you'll have to make many updates :
generate an url for each of you movie pages (By the way, don't use parenthesis in an url, in your example the url should be something like rangoon-2017). You may use my method
seoUrl
store this url somewhere in your database
Decide on an url scheme, like movie/title-of-your-movie
When displaying a link, display the url scheme
create an .htaccess file which rewrites movie/whatever to movie.php?url=whatever
On movie.php, retrieve your movie information from the url and not the id
Additional thoughts :
you'll have to make sure each movie has an unique url. Adding the year is a good idea, since I doubt two movies will have the exact same title and year.
also, make sure your urls are unique in the database (And indexed, since you'll search from them)
why the prefix movie/ on the url ? Simply because if you don't create it, you'll find more difficult to redirect other type of pages to the correct file.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have video website and I worry about if somebody write a script that fetches all my database and use it because i use the video id in address as query string for saying every page which video have to be shown.
Example:
http://example.com/video/215/videotitle
215 is my video id and videotitle is the title of my video, i want to have something like youtube:
www.youtube.com/watch?v=__zj6ibrq04
How can I do this?
i should mention that I used mod_rewrite to get an address like this so I absolutely worry about somebody fetching my database because they can know the video id.
That's awful because id is an auto increment primary key in my database!!!
Is there any suggestion?
If all your pages are public, i.e. anyone can go to any site at any time, there's only one thing you can do against a bot automatically scraping your site: detect scraping behaviour and throttle it. That means you need to track every visitor by IP address and/or other characteristics and start denying them access once they start requesting too many pages within a certain time window. No, this is not trivial to get right.
In this case it doesn't really matter what your URLs look like; you may think that YouTube's URLs are "unguessable", but (most of) YouTube's videos are entirely public and can be discovered by browsing through YouTube's front page. There's no need to guess the URL, that's an irrelevant detail. And even if they were not, you could simply start trying every single URL from __aaaaaaaa trough __9999999. It'll take a while, but it's possible.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Ok. I know that it is title is very confusing, but I do not know how to describe this..SOme tips ? :D
I want to create a page called , let's say -> category.php
On this page you see the parent categories. If a user clicks on this parent I need him go to category.php/parent_category.
On this page he or she sees the children of that specific parent - > And so on until the final page ( in my case a product ) is found.
I know this might sound simple, or maybe a dumb question but for me this is something I have never done before and after strolling on the internet en my LINDA courses I am still empty handed.
Hope someone can help me or lead the way a little bit.
As per OP's wish, comment to answer/answer: (slightly modified)
"On this page you see the parent categories. If a user clicks on this parent I need him go to category.php/parent_category."
You're looking for url rewriting:
http://www.sitepoint.com/guide-url-rewriting/
...and click on the links at the bottom of the page for the continuation.
I.e.: Go to page: 1 | 2 | 3 | 4
Example pulled from the said link:
If your application uses links like:
http://www.downloadsite.com?category=34769845698752354
then most of your visitors will find it difficult to get back to their favourite category (eg. Nettools/Messengers) every time they start from the main page of your site. Instead, they’d like to see URLs like this:
http://www.downloadsite.com/Nettools/Messengers
You can also consult the manual and extensive guide on Apache.org:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
which is done through .htaccess
Plus, if I read it wrong, "pagination" with search capabilities.
I think what you usually do if you want make links that the user can save and use later, but not having to make specific pages for each of them would be to use get data with $_GET[]
That way you'll get links like "category.php?pc=this_category"
But if you specifically want links like category.php/parent_category you might need to rewrite it with .htaccess
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Okay, bear with me. Part of my job is filling out online forms for customers who call in. In these forms there are all kinds of useful information that is hidden in input tags. I would like to make my own page that would extract and display all this useful information. I would also use this page to count the number of times I submit the form throughout the day.
The way I currently have it set up it is in a frameset. The left frame has links to the different forms we fill out, and when I click on one the external form is populated in the right frame. Javascript would be perfect for the job except that my frame is not located on the same server as the forms.
I stink at PHP. Not gonna lie. So i'm not looking for any hand-outs but any pointers would be great.
For example you may check out the forms on http://www.youcangetacar.com and you may use the pin code "A101" or you can check out what I have so far at http://customertrack.host-ed.me/
Make a page that cURL’s the page that is passed to it via url(curl.php?url=http://www.google.com) and then you dont have trouble with same domain policy.
Don’t forget to string replace relative urls with absolute urls.
eg, action="/submit/form.php" must become action="http://www.domain.com/submit/form.php"
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Given a product id, associates have to navigate a vendors website, log in, perform a search, in order to get details on a product for a customer.
My employers want a program that can use the product id, and navigate the vendors website, and perform the search and everything to get the information thus saving the associate from having to manually repeat this task every time a customer wants more information about a product.
I know many sites use methods to prevent (CAPTCHA) exactly what I am trying to do. So I do not know if that automatically makes my given project an "evil" one. But I certainly do not have evil intentions, my employers simply want to save associates time on getting information that they are going to get regardless. However, if this is "evil" please explain why, so I can explain to my employers why we should not go down this road. That being said...
How can I make something like this in PHP?
It depends on what site you are trying to access. Many sites have an API that can be used to access data. If that's not the case, you may need to write a program that loads the html using a GET request, parses through the response, and retrieves the information you want. Without more details, that's the best answer I can give.
To start with I'd recommend reading up on cURL and DOM
cURL: http://php.net/curl (for fetching pages, even simulating search form)
DOM: http://www.php.net/manual/en/book.dom.php (to parse the fetched pages)