"include" comand

+2 mike dunne · November 23, 2014
does the "include" command only work in the index file or can I use it in any file.. because in my register.php file I use the include 'form.php' ; it doesn't work but when I open the form.php file it it works on its own... it just wont work in register.php

Post a Reply


- page 1
Oldest  Newest  Rating
+1 Bucky Roberts · November 23, 2014
It works in any file. Can you post your source code? I will try to find out why it isn't working. 
0 mike dunne · November 23, 2014
this is what I have so far but I thought it should work... I am just learning so go easy on me... I have been watching your videos and learned a lot.. did my first website thanks to you but now I want to register users and having a little bit of a problem.. trying to build a register page... I have a form that I made and I just want to use it at the top of the page to save some space and use the form for other things.. I have a form.php file that works just having a problem linking it to the register.php file...

<!DOCTYPE html>

<?php include 'form.php'; ?>
-1 Franz Schmidt · November 23, 2014
Make sure your filename is correct and also make sure you saved the form.php file in the right folder (may you need to add something to your include path).
0 mike dunne · November 23, 2014
it is in the same folder as the register.php folder.

<!DOCTYPE html>
<?php include "form.php"; ?>

0 Taf Shllaku · November 23, 2014
Try this:

<!DOCTYPE html>
<?php include_once('form.php'); ?>

0 mike dunne · November 23, 2014
this doesn't work also..

<!DOCTYPE html>
<?php include_once('form.php'); ?>

0 mike dunne · November 23, 2014
here is the form.php file
maybe there is something in here that wont let it work in the register.php file
it works fine from the form.php file....

<!DOCTYPE html>
<html Lang="en">
       <meta http-equiv="Content-Type" content="text/html; charset="UTF-8">
    <style type="text/CSS"> h1 {COLOR:blue;} h1 {font-family:"comic sans ms", cursive, sans serif;}
           H2 {background-color:yellow; border: 2px solid blue;} h4 {font:18px "comic sans ms", cursive, sans serif;}
     #form-wrap{width: 600px; border: 3px solid blue; background-color: lightblue; margin: 50px auto;
     padding: 20px 20px;}
     label{display:block; margin: 5px 0 5px 5px; font: 18px "comic sans ms", cursive, sans serif;}
     input{width:300px; margin: 5px;}
           textarea{width:300px; height:50px; margin: 0 0 0 5px;}
        fieldset{border:1px solid blue;}
     <H1 Align="CENTER"> LuckyPuppyOptions </H1> <!-- Header -->
  <!-- 09 03 2014 -->
  <H2 Align="CENTER"> Register </H2>
  <hr />  <!-- line -->
  <p align="center"><a href="index.html">Home </a>
   <div id="form-wrap">
       <form action="contact.php" method="post">
           <fieldset> <h4>Contact Us</h4>
           <label class="labelone" for="name">Name:</label>
             <input name="name"/>
              <label for="email">Email:</label>
                <input name="email"/>
     <label for="comments">Comments:</label>
       <textarea name="comments">
0 Franz Schmidt · November 23, 2014
Tried your code and everything looks nice.
Really don't know what could be wrong but there only can be a misstake with the filename or the filelocation. :(
0 mike dunne · November 24, 2014
the file name is form.php

I tried it the way you recommended also cant get it to work ive checked the path and location.. I put it in a file called register.php like this..

<!DOCTYPE html>
<?php include 'form.php'; ?>


the form works just not in the other file path and filename are good checked and rechecked... going crazy
0 mike dunne · November 24, 2014
do I need another file to make the include work
  • 1
  • 2



Server-side, HTML embedded scripting language used to create dynamic Web pages.