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
Related
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.
This question already has answers here:
How to load a PEAR package
(2 answers)
How can I get useful error messages in PHP?
(41 answers)
Closed 2 years ago.
I'm running Buster on my local server which, among other things, I use for developing web sites before copying them onto a public host. I've recently been getting into a little php coding because there seems to a lot of sample code out there for things I want to do. Usually they work right away when I try running them after having installed libapache2-mod-php.
Right now I'm trying to get a script working that is actually fairly small and seems straightforward. It displays a form that allows you to send an e-mail with an attachment. I actually have some similar scripts working locally that do pretty much the same thing, but I'm trying to get this one to work because the host I use for one site that needs this type of form has broken the script I had been using (I also didn't like it because it seemed overly complicated and under-featured).
This script use the Pear libraries to handle the heavy lifting, which seems like a reasonable design decision. I installed the php-pear package and also php-mail-mime. Unfortunately, the script failed to work. It was uploading the file but failing to send the e-mail.
I was able to find the line that was failing but it puzzles me. The line is
$message = new Mail_mime();
which should be working (all it's doing is creating a new object). I ran the (frequently recommended) php-info page (<?php phpinfo();) and it shows a lot of information but nothing about mime. I'd expect that is something php handles though.
I got the script to send an e-mail by removing all the mime parts and just using the php mail() function. However that's not really useful. I need the mime bits to add the attachment.
Anyway, it looks like I need to do something more (besides restarting Apache2) to get php to use the php-mail-mime library but I'm not sure what. All the Debian information I've found just says "install the package php-<whatever> and it will work". Can anyone help me here?
This question already has answers here:
Website screenshots
(18 answers)
Closed 6 years ago.
I need to take screenshots of few web pages and save them in a folder using php.
I want to do this using a php script, is there a way I can render those webpages and take screenshot of a particular area after the website is fully loadedd? - I'm using windows.
I tried using wkhtmltoimage but it takes low quality screenshots and also it takes the screenshot before the whole page is loaded, so some images of the webpage are not appearing in the screenshot, is there a way to do this using php?
Please help php specialists. Thank you
PHP runs on server side, so to be able to take screenshots you need something to render HTML (a browser-like script) and generate a image of it. This script will do that (wkhtmltoimage too):
HTML2PS:
http://freecode.com/projects/html2ps_php
But I still think the best solution will be using javascript. Of course, only the client will have access to the screenshots, and maybe you can upload the image to the server. A client browser is better than any kind of server script.
If that is the case, I would suggest using HTML2CANVAS:
HTML2CANVAS: http://html2canvas.hertzen.com/
The best server solution will be a linux distribution with a google chrome installation and a local script to take screenshots. That is the only way to get accurate screenshots of a web page that may contain javacript/HTML5/animations and other difficult to render stuff.
JavaScript / HTML5 / Canvas
It could be hard to code it only in PHP. In your case I think I would follow those instructions:
Using HTML5/Canvas/JavaScript to take screenshots
PHP
Or if you really want use only PHP, it should help you:
Website screenshots using PHP
This question already has answers here:
Access php files through a link on the web
(3 answers)
Closed 8 years ago.
Okay here's the scenario:
Suppose I'm already done designing and coding a website (in PHP, HTML, CSS and other stuffs that help create a website functional) which is still sitting on my desktop, the question is "What's next? How do I publish it to the web?"
Please help, I've seen some tutorials but couldn't understand them.
Well, once you got your website, next step is to find a hosting to place it.
Take in mind, if you are going to "free hosting", some of them don't allow PHP files.
Once you got it, I'll reccomend you a FTP client, such FileZilla or similars, to upload your content to the hosting. Make sure, of course you got a page called index.php/index.html, so it will be loaded when you type in your website.
You need to learn about How to do web hosting
And so many things like
Domain registration
Webserver
and so many.You can have a good and simple tutorial for a beginner in the reference link.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Question about php and dreamweaver?
I am having alot of trouble running my php file. I downloaded XAMPP and have both Apache and MySQL running. Do I need to save the file in a certain place, and what does Dreamweaver mean when it says:
To preview pages containing server-side code, you need a testing server. Would you like to specify one now?
I have good enough knowledge in HTML and CSS, and have gotten websites running, but I can't seem to get PHP to work. When I just run the code from google chrome plainly it looks like this:
"Hello World"
"; phpinfo(); ?>
You can put your PHP-files into the xampp/htdocs folder, e.g. xampp/htdocs/hello.php and then open it in your browser at http://localhost/hello.php.
The URL must say localhost or whatever you set it to in order to render a PHP page. You also need to make sure PHP handlers are working and correctly parsing PHP files.