October 4, 200917 yr Ive downloaded WAMP to start messing around with PHP cos I want to include a PHP form on my website. I am just a bit unsure about how it all works i.e just to test it locally for now. I followed tutorials to edit the 'Splash' page which works all well and good, but when I try and start a new PHP page I can't seem to get it to show anything. Do I need to save the file in the same folder as the Splash page? I've tried this but alas it does not work. Thanks
October 4, 200917 yr Author edit: when I press the 'admin' button on the XAMPP control panel I see the url is http://localhost/xampp/splash.php, whereas if I try and preview through notepadd++ the url is file:///C:/xampp/htdocs/xampp/splash.php, which then doesn't show anything. So I guess my question is - how do I ask notepad to preview my page through the local server? Thanks
October 4, 200917 yr Author edit#2 - when I click that link I posted above it says 'Object not found' even though the URL is exactly the same as the the URL for the admin button, which works! Is this normal??? Sorry for the gabble so early on a Sunday
October 4, 200917 yr The file should be parsed by the server, then previewed by a browser, so you can have notepad and your fave browser open on the same file at the same time, then refresh the browser when you want to see the changes you have saved. you will need to navigate to the page you want, like http://localhost/yoursitefolder/index.php in your browser, but leaving it as the explorer route in notepad ( file:///C:/xampp/htdocs/yoursitefolder/index.php )
October 4, 200917 yr Author Ok Ive got that to work now - that link I posted didnt work because it has a comma at the end doh! Im using Jem's PHP form http://www.jemjabella.co.uk/php-scripts#php-mail-form which all fits into a php file. How would I go about including this in a web-page? Does CSS work on PHP files too, or that that part need to relate to the html on the webpage?
October 4, 200917 yr Just think of a php page as a normal html page, with .php on the end, everything like CSS, Javascript etc stays exactly the same. I haven't looked at Jem's form in detail, but PHP form's generally work in one if two ways 1. (my fave) the form handling information is included on the on page (usually in the head), and the form action is left blank or '#' 2. (not my fave) a separate PHP file handles the form, so the form action will be e.g. 'formhandler.php' and then it redirects the user to a new page afterward.
October 4, 200917 yr Also, if you want to test your mailing form, you will need to set up a mail server, as the local server won't have one built in, I use Argo soft, which is free and takes a little setting up, but will let you know if the form is working before you go live.
October 4, 200917 yr Author So basically the web page with the contact form on should be a php file, rather than being a html file with an embedded php form?
October 4, 200917 yr So basically the web page with the contact form on should be a php file, rather than being a html file with an embedded php form? Any web page that contains PHP code should be prefixed .php instead of .html. PHP code is a way of introducing "server side" logic to a web page and will typically generate html commands. The PHP code is contained within the following tags <?php .... php code ..... ?> Within this code you will probably see it generating html commands via "echo" statements. To test PHP programs on your local machine you can downlaod a WAMP server product (PC) which will enable you to test PHP programs and interface with a MySQL database.
October 8, 200917 yr Author So is there any harm in labelling all your web pages with .php instead of .html, in case you want to add any php scripting onto it at a later date?
October 8, 200917 yr So is there any harm in labelling all your web pages with .php instead of .html, in case you want to add any php scripting onto it at a later date? If you think you will be using PHP later it's a good idea, that way when you do alter them you won't have to change all the links to your pages
October 8, 200917 yr Author Yeah that's what I was thinking, but is it bad practice to label it a php file if there is no php in it?
October 8, 200917 yr Author Yeah that's what I was thinking, but is it bad practice to label it a php file if there is no php in it?
Create an account or sign in to comment