Problem: I'm creating a website right now, it's my first time dealing with PHP after learning the basics. My index.php file, when viewed on my localhost, is attempting to download the file and bring up the file explorer prompt. Does this on both Chrome and Edge.
Troubleshooting:
I removed the file association.
Tried on Edge browser.
Looked online for answers. All other YouTube videos & forums I found including StackOverflow had previous questions about this but the answers were either outdated by like 10+ years or just didn't for me.
What do I do? Any help is appreciated, and reminder I'm new to PHP so please no super veteran-sized solutions, thanks.
Edit 01: I was told to share my URL so here it is:http://127.0.0.1:5500/index.php
Edit 02 (Solution): I didn't realize that the Live Server plugin for VSC was only for static HTML pages and not PHP pages. WebPajooh helped me with setup how to achieve a similar result using XAMPP.
It was better to share your URL. I guess you are trying to access the PHP files by entering the file path, not the URL.
https://localhost/some_directory/some_file.php
If you are doing this, not entering the file path directly, check your web server configurations.
Related
This question already has an answer here:
Why my contact form (php) does not work with GitHub pages?
(1 answer)
Closed 12 months ago.
So i was adding a .php file to my github website with an email sender form, but when i try running it on my website it makes me download it instead of making it run directly in the browser. I was also trying to research something and i saw something about apache, but i don't know how to do it and how it works.
What i tried is to change the extension to .html but unfortunately, it sended me a 405 error "not allowed".
I'm sure the code is right and the only thing is that it dosn't make me run it.
What i want is that the php file, runs on the browser instead of making me download it.
Assuming that by GitHub Website you mean GitHub Pages...
You can't.
GitHub websites are mostly static - you, as a developer, push html or markdown and github provides/generates static content for viewers/browsers.
If you want to have a PHP-based backend, you need to use a different service. Alternatively, if your PHP code can generate static html, you can run it in a github action and push the html into github pages - but once done, it will stay as is until the next run.
Edit: also check the video on their site, which among other things, says:
There are no databases to set up or servers to configure
I am new to the web app development and server topics so my question is rather theoretical. I’ve searched and went through a lot of related topics but haven’t found any satisfying answer and explanation:
Lately I was trying to write a rather simple PHP/html web app to display the content of my local dir let’s say C:/Users/Desktop and generate hyperlinks that would redirect me to the subfolders (and ideally open files in it)
I tried a lot of ready solutions but they were very outdated (3 or 4 years ago) then I found out that it is impossible on all web browsers because of security reasons. From what I learned it is only possible when browsing files on a server but I don’t really know how to enable it locally on my PC.
Could anyone explain to me why it is so? Or if it’s any way to pass it?
Thanks in advance, best regards.
You can easily install a local server (including php runtime) on your PC, like https://www.apachefriends.org or http://www.wampserver.com
A simple guide: https://blog.udemy.com/xampp-tutorial/
List files: List all files in one directory PHP
Hello and thanks in advance for the help. I am running a LAMP server on my raspberry pi and I need help creating a registration and login page using mysql database. All my php files have to be in the /var/www/html. I've been googling this for about a week and I have some questions.
Where do I save css files
Can I make a subdirectory in the html that will create a website (I have tried to do this already but when i navigate to the site it tells me the page isnt working)
How do I make it secure (this is for a personal project so it doesnt have to be extremely secure I just want to know some common security issues)
I tried to follow http://www.allphptricks.com/simple-user-registration-login-script-in-php-and-mysqli/ steps and it showed nothing but a blank page.
I am not asking someone to just write all the code for me, I want to learn and understand what I am doing wrong so if you could direct me to a better tutorial or explain it that would be great.
Thanks
First off make sure all of your CSS files paths are set correctly in the HTML files that you are trying to style. As long as the CSS files are included correctly then it should style your page. The final destination of the CSS files should not matter as long as you have the correct path set to the CSS file in the HTML file.
Linking a CSS file to an HTML file W3Schools
All I did was search "mysql php security best practices" I'm sure you can find more but here is what I found (the first link in my case) OWASP
I came across a website and liked its look. So, I wanted to know how its style.css is coded.
I got there style.css file by visiting to Network Tab of Inspect Element and then opening that file in a new tab. We can open JS files also in the same way.
But, how can I open a PHP file? I know the directory where the PHP file of that website is located, but when I type that directory in the browser's address, it shows a blank page (full white blank page with nothing on screen), so I thought I need PHP installed on localhost.
So, alternatively, to get the PHP file, I downloaded that file and opened it in Sublime Editor, but there too, it shows blank.
So, how can I get that PHP file?
[Note: This is just a question for educational purposes. This thought suddenly came in my mind when I was going through that CSS file and just for the sake of my anxiety and knowledge, I'm asking this question. No offense or criminal minded tendency..]
It´s not possible. PHP files are executed on server side and can´t be downloaded like HTML files.
More information on this can be found here:
StackOverflow: Can a client view server-side PHP source code?
Can someone steal my PHP script without hacking server?
security.stackexchange.com: Is it possible for a hacker to download a php file without executing it first?
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
A simple hello world NPAPI plugin for Google Chrome?
How to open a file which includes in Chrome extension by C/C++?
originally i wanted to develop a chrome extension to open a file on the user's pc.
I wanted to use php fopen some SO users said that I have to use NPAPI instead and said that this is a duplicate question and deleted my question.
I just want to know why can't I use fopen? And if i really don't have other options, then how to open a file using firebreath?
When i go to this section of the docs i don't see the snippets.
i know that moderators gonna come to my question saying that this is a dupe and link to this question I'm one step ahead lol
I don't understand a thing from the accepted answer and i don't understand what file he edited.
the second answer give this link but i can't see the snippets! can you?
I'm on linux mint 12, 32 bit
let me change the question. Can i do this in java? Flashgot got some jar files in the source code :)
install flashgot using chrome, a file called flashgot-1.3.9-tb+sm+fx.xpi will be downloaded, change that to flashgot-1.3.9-tb+sm+fx.zip unzip it and go to the chrome folder
Can i do it in python? every linux distro has python by default
I just want to know why can't I use fopen?
Because JavaScript isn't C.
More generally, there's no way for arbitrary web pages to run arbitrary native code on your computer because otherwise clicking a link could take you to a page that would steal every file on your computer and then erase your hard drive.
If you use firebreath then you're in C++, so you can use fopen if you wish. Keep in mind that you would have the same privileges as the browser, which running as a user probably can't write places like Program Files, etc.
You can't use fopen in javascript. I don't know why a "building firebreath on linux" page would ever have snippets on how to open a file; since firebreath is just C++ I don't know why we'd need to add docs for opening a file at all.. it's just C++. Open a file like you would in any other C++ application.
The other question has all the information you need to figure out where your file is; they didn't include specifics on how to do the operation itself because you don't need those specifics; you can get them anywhere. Try googling "open a file in c++" and you'll get lots of hits.