S
S
Sergey Chistyakov2014-04-13 00:00:22
PHP
Sergey Chistyakov, 2014-04-13 00:00:22

Localhost or full path to php script? What is their difference?

Problem. I write a script in php, I work with Denver. I am creating a form to submit to the data server. The form has a multi-line textarea and two buttons - submit and reset. I launch this form in Firefox. I write data in the field and by clicking on the button I send them on a journey, but... when I go to the form from ./localhost/form.html and send it to ./localhost/script.php everything works, but if I go with the full_path_with_disk/localhost /form.html and send it to the full_path_with_disk/localhost/script.php , then it gives me the script code and does not listen to me at all. I understand that it is better to access via localhost , but explain why it does not work with the full path?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Chekalin, 2014-04-13
@piro1107

Stop! If Denwer, then you are not talking about ./localhost/..., but about http://localhost/... ? Or are you talking about the fact that there is a ./localhost/ directory in which the site files are, and you open the form as a file from disk?
The path "on the disk" (it is also opening at file://...) is the opening of the file by the browser as it is, without working out php and other things. Opening via http://... - the web server will read the file, execute it, and give your browser the result of the work (for example, a message that the form has been processed).

L
lubezniy, 2014-04-13
@lubezniy

To begin with, carefully study what is the client part of the application, and what is the server part, and which of these should work where. And learn that the client part (what is executed by the browser) should not access the disk of its computer (normal browsers now do not allow sites to take such liberties), but to the server where the server code is executed (it doesn’t matter if it’s PHP, Perl, Python, JSP, ASP, or something else) that generates and sends to the client a response processed by the browser (HTML, JSON, XML, or something else).

A
Alexander Borisovich, 2014-04-13
@Alexufo

localhost is a synonym for 127.0.0.1, the reserved address of any local machine. That is, addressing itself as a remote server.
If you want to access your file system via file:// through a browser, then any site can download anything from your computer and it will not allow it on its own. It will, if the web page is opened from a local disk (saved to disk, but this is not about that), then the file:// protocol works. For documents from the network, this is prohibited.
You read any book on php. You simply do not understand the client-server architecture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question