How to view php files on a web page

Discussion in 'Web Design and Development' started by JLEW700, Jul 15, 2009.

  1. JLEW700 macrumors 6502

    Joined:
    Aug 12, 2008
    #1
    Hi, Im trying to set up a login page by following this tutorial: http://www.youtube.com/watch?v=4oSCuEtx ... annel_page. I have all the code correct and saved both the "index.php" and "login.php" files. I downloaded XAMPP and turned on apache and mysql and followed the steps to set up the database at http://localhost/phpmyadmin/. My problem is that when I click on the index.php and login.php file, they just open up in textedit, can anybody tell me what to do to get these to open like the guy does in the video. Also, I prefer using my mac, but I can also do this on a pc.

    Basically I want to know what I need to do so that I can view my php files on the web instead of in textedit

    Thanks, Jeromy
     
  2. TodVader macrumors 6502a

    TodVader

    Joined:
    Sep 27, 2005
    Location:
    Quebec, Canada
    #2
    It seems like you don't have a PHP server. If you just have a regular Apache server without PHP, you won't get anything but text output from a PHP file. Apache and MySQL won't be enough.
     
  3. Mal macrumors 603

    Mal

    Joined:
    Jan 6, 2002
    Location:
    Orlando
    #3
    TodVader, XAMPP includes PHP.

    OP, the biggest problem I ran into first setting this up was that I didn't place my files in the right directory. Look in the XAMPP settings and make sure that the right directory is set. The other trick is that XAMPP won't set your file associations so that simply double-clicking them will open them in your browser. Try just dragging the files to the Safari icon to open them there, and see if you get the source code still or if it's processed and displayed correctly. To set that more permanently so you can just double-click them in the future, Get Info on the files and change the Open With... dropdown to Safari (or Firefox, whatever you use).

    jW
     
  4. m3kilpat macrumors regular

    Joined:
    Jul 6, 2009
    #4
    XAMPP comes with PHP.

    You need to put the files into your public_html folder located in the Apache folder (if there is no Apache folder perhaps in XAMPP folder...I've always installed everything manually so I'm not sure about that but definitely the public_html folder).
    Then point your browser to localhost/index.php

    That should do it.
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    For XAMPP/MAMP it will be the htdocs folder inside the XAMPP folder.

    @OP
    You mentioned you "clicked" on those files. Where from exactly? Generally you'll just type them into your browser to access them.
     
  6. m3kilpat macrumors regular

    Joined:
    Jul 6, 2009
    #6
    Woops that's what I meant
     
  7. TodVader macrumors 6502a

    TodVader

    Joined:
    Sep 27, 2005
    Location:
    Quebec, Canada
    #7
    I know that it includes PHP but he said he accessed his files with localhost so they should work. It still seems like the PHP server is down.

    If you have an Apache server with PHP and MySQL and PHP crashes, your server WILL output only text with PHP files. That's why Apache should crash at the same time to avoid getting passwords revealed from the files. Even if you shouldn't keep passwords in the tree, some do.

    If he just clicks on the files, he just doesn't really know what he's doing :confused:

    You need your server to process the files by accessing them with a browser.
     

Share This Page