How to change a webpage from .html to .php [closed] - 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 1 year ago.
Improve this question
I have made a webpage using .html and I would now like to change it to .php so I can connect it to a database. I have changed the file extension to .php but now it just opens the actual code in the browser as opposed to opening the website. I have googled it but all I can find is stuff about installing .php on a server, when I am just trying to open the file on my device. I am using Microsoft Edge if that matters. What do I do?

First of all, what you have to understand is php is a server side language whereas html is a client side language. As you might already know, html can be directly interpreted by browser but for php, the case is different. You need to have a server installed.
Moving on to your question How to change html to php!!, it's simple, just change the extension of the file.
To run the file, use local server. There are many options you can choose from. Personally I find Xampp easy to setup for beginner. It's my personal opinion though.
To sum up, to change html from php, install a localhost or local server to your computer, migrate your files to server's run directory. You can find plenty of tutorials on setting up localhost.

If you want to run a PHP file after changing its extension. You need to install xammp or lamp server. In the localhost server, you can view your PHP pages on any browser.

Related

Steps to develop a website to upload files [closed]

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 am planning to develop a webpage where anyone can upload a file. I want to do this because I want to make a webpage where my friends can upload a file, if they think that that file will help others (eg: a free tutorial pdf on Unix).
To develop and test this webpage what is needed ? As far as I think now:
Webserver ? I tried installing apache2 but had some issues
mysql-server ? I installed mysql-server ,but have issues with creating user for db
php
What else would I need ? (Assuming 'download' functionality will be added later, NOT NOW)
I am developing this in Ubuntu 12.04
Thanks
You don't need MySQL for the problem as described. All that would be required is a web server with a working PHP install. You can see the PHP documentation for how to handle the file uploads.
once you have installed and configured wamp/lamp.
platform(window, linux) doesnt matter a web application is not platform dependent. wamp/lamp will install mysql(database server), and apache(web server). thirdly determine you web scripting language(php, jsp, asp ect).if php, your php scripts must be executed by the web server ie you have to place them under c:\wamp\www\sitefolder\
How to: http://www.w3schools.com/php/php_file_upload.asp
you can test if on your local machine
then with Apache running, type in your browser www.localhost\sitefolder\yourscipt.php.
assuming you have an active domain and hosting account you may need to consider the
::::
-determine the upload size limit, location, and file type on the php
-you may require/though not a must client side scriptiing jquery- ajax for asynchronous requests.
-security will be of concern, you dont want some harmful data scripts on your site.
verify upload limit with your hosing provider..

Can PHP pages be run locally? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Can PHP pages be run locally?
I am trying several demos on creating a contact form, at the moment I am trying this one:
http://www.html-form-guide.com/contact-form/php-email-contact-form.html
I have downloaded the source files and put my own email address in, but when I click submit I get directed to the PHP page. The form's action attribute is set to that PHP page, so I was wondering if it is because PHP is not able to run locally? If I want the form to submit and send to my email would I need to put the downloaded source pages online to make them work?
This is not the only tutorial I've used where this happens.
Sorry if this is a silly question - newbie web developer :).
Thanks.
PHP, in this context, is a server side language. It must be run by a webserver.
The webserver can be installed and run locally.
PHP needs to be executed server-side, which means you will need to set up a local webserver.
The best way to go would be taking a look at WAMP or MAMP or LAMP, depending on your operating system.
You need to be running a PHP server locally, and have the file "hosted" by the server (in the same folder, but usually /var/www/). There are a verity of free programs for this. I like WAMP ( http://sourceforge.net/projects/wampserver/)
You should simple install WAMP server. If you use Windows I recommend this one: http://www.easyphp.org/
When you install it you should copy php file to projects directory and then you can run in your browser http://localhost/projects/ to see your file and to execute it

No idea what to do with a pure php page [closed]

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 am trying to implement an already coded image upload system which has been written purely in php. I have a html website but did not know that I could direct users to a pure php page. Surely it would just show in a browser as coding. How do I make this pure php webpage into a html webpage? I am new to web design so any help is muchly appreciated.
Would I have to implement it as an iframe within a html page?
Thanks
The output of the PHP program just needs to be an HTML document (unless you override it, it will output a text/html content-type so you only have to provide the HTML document itself).
There is no need to involve iframes.
Surely it would just show in a browser as coding.
No, unless you are using a server which does not support PHP or have not configured it correctly, the PHP will be executed on the server and the output delivered to the browser.
Install PHP with Apache. If you are feeling tough to install it manual, go to www.apachefriends.org, find the suitable version of XAMPP for you, download and install in in your machine.
Make sure you install the Apache service. This will make Apache to run whenever you boot your system.
Move your PHP, HTML and all associated CSS, JS files to the following folder path, C:\xampp\htdocs\YOUR_FOLDER_NAME
In your browser, you can open the files as http://localhost/YOUR_FOLDER_NAME/FILENAME.php.
Now you will see it as processed HTML page. This will work for both your HTML and PHP pages.

What's the best way to update PHP files to live server? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am accessing my remote server directory(/var/www) using the tool WINSCP. When I need to update a PHP file on the remote server, I work on a copy on my laptop (Windows 7), then I upload that copy to the corresponding directory at the remote server (by clicking right click on the file on the laptop directory, then I chose upload from the menu, then from the prompt I chose move and replace).
My question, during the transfer process, assume there is a user is using the system and he made a process was not done yet (let us say a process in mysql was working) and suddenly the PHP file is replaced with another one during the process. Will this make problem for my application? Is it healthy? Will it stop or a corruption will happen to database?
Shall I kick out all users before replacing PHP files at remote server? (that would be so hard option).
PHP read the whole script before running it, so replacing the file will have no effect on this, you can keep doing it like that.
If you have multiple PHP files and you are changing the API between them (add parameters to functions in your lib, for instance), you could run into trouble.
Same is if you use a database and you have to update your table definition.
As long as only a single PHP file changes, you are completely safe.

Upload/retrieve files from a linux based file server using PHP [closed]

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 2 Linux boxes with same version installed. The first one is used to host a apache/linux based web site and the second one is used to host user supplied files.
The webserver box can access the file server box using an internal IP address. When user tries to upload a file using my php web site, I need to save this file in a specific folder in the file server box.
One option I found until now is to use PHP's FTP functions. Are there any other/better options to access folders/files that reside on a file server box from the web server box?
Thanks for any help!
- Jaideep
Configuring an NFS server on the file server, and mounting the exported directory on your web server, will make programming easier for you, because you can access the directory just as if it was local.
In an environment where you don't have professional system administration, i'd recommend against the NFS version however, because NFS needs some planning regarding synchronized user ids, and it doesn't always recover gracefully from a crash (although it should, in theory). From that point of view, FTP might be your best option.

Categories