Help with PHP code in include file. Thanks

Discussion in 'PHP' started by learnwebsitedesigncom, Dec 22, 2010.

  1. #1
    Hi everyone, I need some help correctly adding some php code in an include file. What I am trying to do is have 2 include files: one with the php code to process a form and another separate file to hold the html/php code for the form itself. The php code and form work, however, when I try to include the php/html form for the form it does not work.

    The php/html form code that I'm trying to put into an include file is shown below:

    
    
    <form action="<?php htmlentities($_SERVER['PHP_SELF']); ?>" method="post" class="form_advertise">
    
    <p>
    
    <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
    <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
    <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
    
    <div class="cell_container">
    <div class="cell_one">
    First Name:
    </div><!-- end class cell_one -->
    
    <div class="cell_two">
    <input type="text" name="first_name" value='<?php echo "$first_name"; ?>' size="25" />
    </div><!-- end class cell_two -->
    
    </div><!-- end class cell_container -->
    
    <br />
    
    <div class="cell_container">
    <div class="cell_one">
    Last Name:
    </div><!-- end class cell_one -->
    <div class="cell_two">
    <input type="text" name="last_name" value='<?php echo "$last_name"; ?>' size="25" />
    </div><!-- end class cell_two -->
    </div><!-- end class cell_container -->
    
    <br />
    
    <div class="cell_container">
    <div class="cell_one">
    Email:
    </div><!-- end class cell_one -->
    <div class="cell_two">
    <input type="text" name="email" value='<?php echo "$email"; ?>' size="25" />
    </div><!-- end class cell_two -->
    </div><!-- end class cell_container -->
    
    <br />
    
    <div class="cell_container">
    <div class="cell_one">
    URL of Host:
    </div><!-- end class cell_one -->
    <div class="cell_two">
    <div class="float_left">http://</div><!-- end class float_left -->
    <input type="text" name="host" value='<?php echo "$host"; ?>' size="25" />
    </div><!-- end class cell_two -->
    </div><!-- end class cell_container -->
    
    <br />
    
    <div class="cell_container">
    <div class="cell_one">
    URL of Hosted Website:
    </div><!-- end class cell_one -->
    <div class="cell_two">
    <div class="float_left">http://</div><!-- end class float_left -->
    <input type="text" name="url" value='<?php echo "$url"; ?>' size="25" />
    </div><!-- end class cell_two -->
    </div><!-- end class cell_container -->
    
    <br />
    
    <div class="cell_container">
    <div class="cell_one">
    Message (DO NOT enter any HTML code in the message):
    </div><!-- end class cell_one -->
    <div class="cell_two">
    <textarea name="message" cols="50" rows="10">
    <?php echo "$message"; ?>
    </textarea>
    </div><!-- end class cell_two -->
    </div><!-- end class cell_container -->
    
    <br />
    
    <div class="cell_container">
    <div class="submit_button">
    <input type="submit" name="send" value="Submit Form" />
    </div><!-- end class submit_button -->
    </div><!-- end class cell_container -->
    
    </p>
    
    </form>
    
    
    HTML:
    Thanks
    Jose
     
    learnwebsitedesigncom, Dec 22, 2010 IP
  2. Minimal Hank

    Minimal Hank Peon

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to show us the rest of your code ( you said you have more than 1 file ) as the problem most probably isn't in HTML but PHP.
     
    Minimal Hank, Dec 25, 2010 IP
  3. Brad.V

    Brad.V Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try:
    <?php
    include("./file.php");
    ?>

    That will include what ever is placed in the file.php file.
     
    Brad.V, Dec 25, 2010 IP
  4. Alastair Gilfillan

    Alastair Gilfillan Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #4
    Confirm that the form works as one before splitting it into your inclusion files. Once it is working, as Brad.V says above, include('form.php') has to work. :)
     
    Alastair Gilfillan, Dec 26, 2010 IP