SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    0 Post(s)
    0 Thread(s)

    General Help For PHP Beginner

    Hi, I've just started with PHP and MySQL and I'm building a website using Dreamweaver 8, I've just done the design and now I have to program it. Thus far, I have created a database and have let Dreamweaver handle the PHP code to retrieve data from the DB, as result, I got all the codes mixed up into a single file (PHP and HTML), my questions are, should I separate the HTML from the PHP codes? Should I create a "header.php" and a "footer.php" and include them into a "main.php"?

    Another thing that I have to concern is security, does Dreamweaver provide the necessary security? Or do I have to "path" the codes by myself? If so, can you tell how?


  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Lancaster University, UK
    2 Post(s)
    0 Thread(s)
    One thing that I will say is for PHP coding, keep well away from programs that write the PHP for you. Don't let it become a habit to use.

    Anyway, i would recommend having header and footer files, as if you need to edit something, you just need to edit one file.

    Another thing i would recommend is putting all the database connection information in a file called db_connect.php, and put it into a directory that no-one can access, e.g. the same directory that public_html / htdocs is in, then include it in the header file. PHP can access files above the directory that users can access. This helps if APACHE fails and people can see your code, they won't be able to see the file and connect to your DB.

    Also, I think it's best to keep the PHP code in the same file as the HTML, unless its a function or whatever.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts