dcsimg
www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: PHP and HTML

  1. #1
    Join Date
    Dec 2015
    Posts
    8

    PHP and HTML

    Ok, I have 2 scripts, 1 html, 1 php. On their own they work perfectly. I just want to incorporate the php form into the html form, but the php form does not show up. Yes I have the link right and yes my server supports the php as it runs fine on its own.

    Here is the html:

    <div class="wrapper coloured bgded overlay" style="background-image:url('images/demo/backgrounds/01.png')">
    <div class="hoc container clear">

    <div id="newsletter" class="hoc clear">
    <!--
    <?php include 'form.php';?>

    <!--
    </div>
    </div>
    </div>

    Here is the php:

    <?php

    if( !defined('FormmailMakerFormLoader') ){
    # This block must be placed at the very top of page.
    # --------------------------------------------------
    require_once( dirname(__FILE__).'/form.lib.php' );
    phpfmg_display_form();
    # --------------------------------------------------
    };


    function phpfmg_form( $sErr = false ){
    $style=" class='form_text' ";

    ?>




    <div id='frmFormMailContainer'>

    <form name="frmFormMail" id="frmFormMail" target="submitToFrame" action='<?php echo PHPFMG_ADMIN_URL . '' ; ?>' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onSubmit(this);'>

    <input type='hidden' name='formmail_submit' value='Y'>
    <input type='hidden' name='mod' value='ajax'>
    <input type='hidden' name='func' value='submit'>


    <ol class='phpfmg_form' >

    <li class='field_block' id='field_0_div'><div class='col_label'>
    <label class='form_field'>Company Name</label> <label class='form_required' >&nbsp;</label> </div>
    <div class='col_field'>
    <input type="text" name="field_0" id="field_0" value="<?php phpfmg_hsc("field_0", ""); ?>" class='text_box'>
    <div id='field_0_tip' class='instruction'></div>
    </div>
    </li>


    <li class='field_block' id='phpfmg_captcha_div'>
    <div class='col_label'></div><div class='col_field'>
    <?php phpfmg_show_captcha(); ?>
    </div>
    </li>


    <li>
    <div class='col_label'>&nbsp;</div>
    <div class='form_submit_block col_field'>


    <input type='submit' value='Submit' class='form_button'>

    <div id='err_required' class="form_error" style='display:none;'>
    <label class='form_error_title'>Please check the required fields</label>
    </div>



    <span id='phpfmg_processing' style='display:none;'>
    <img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&amp;func=processing' ;?>' border=0 alt='Processing...'> <label id='phpfmg_processing_dots'></label>
    </span>
    </div>
    </li>

    </ol>
    </form>

    <iframe name="submitToFrame" id="submitToFrame" src="javascript:false" style="position:absolute;top:-10000px;left:-10000px;" /></iframe>

    </div>
    <!-- end of form container -->


    <!-- [Your confirmation message goes here] -->
    <div id='thank_you_msg' style='display:none;'>
    Your form has been sent. Thank you!
    </div>









    <?php

    phpfmg_javascript($sErr);

    }
    # end of form




    function phpfmg_form_css(){
    $formOnly = isset($GLOBALS['formOnly']) && true === $GLOBALS['formOnly'];
    ?>
    <style type='text/css'>
    <?php
    if( !$formOnly ){
    echo"

    ";
    }; // if
    ?>



    <?php phpfmg_text_align();?>



    <?php
    }

    ?>

  2. #2
    Join Date
    Aug 2006
    Posts
    2,007
    Does your html really have this opening comment right before all the php?
    Code:
    <div class="wrapper coloured bgded overlay" style="background-image:url('images/demo/backgrounds/01.png')">
    <div class="hoc container clear">
    
    <div id="newsletter" class="hoc clear">
    <!--
    <?php include 'form.php';?>
    ...

  3. #3
    Join Date
    Dec 2015
    Posts
    8
    ya why ? im still learning this, so be nice.

  4. #4
    Join Date
    Aug 2006
    Posts
    2,007
    Well it's an opening comment, so any html between it and the corresponding closing comment (-->) won't be displayed. Since I don't see a closing comment, that may be to the end of the page, and is a good reason you're not getting anything on the screen.

  5. #5
    Join Date
    Dec 2015
    Posts
    8
    That was actually a typo. It is actually like this:

    <div id="newsletter" class="hoc clear">
    <?php include 'form.php';?>

    </div>

  6. #6
    Quote Originally Posted by tracknut View Post
    Does your html really have this opening comment right before all the php?
    Code:
    <div class="wrapper coloured bgded overlay" style="background-image:url('images/demo/backgrounds/01.png')">
    <div class="hoc container clear">
    
    <div id="newsletter" class="hoc clear">
    <!--
    <?php include 'form.php';?>
    ...
    I also agree with you.

  7. #7
    Join Date
    Dec 2015
    Posts
    8
    Ok, can someone please deleat this post so I can start over. There is no <!-- in the script, that was a typo. the proper script is as follows and still does not work:

    <div id="newsletter" class="hoc clear">
    <?php include 'form.php';?>
    </div>

  8. #8
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,198
    Is the file a PHP file? You aren't trying to insert that PHP code into an HTML file right?
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  9. #9
    Join Date
    Dec 2015
    Posts
    8
    Yes it is

  10. #10
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,736
    Start the main file (whichever file is actually called via the URL) with the following:
    PHP Code:
    <?php
    ini_set
    ('display_errors'true); // change to false in production
    error_reporting(E_ALL);
    ?>
    Then see if it tells you anything useful. Also, if your editor does not detect PHP syntax errors, you can run the following from a command line that has PHP in the path:
    Code:
    php -l filename.php
    (That "-l" is a lower-case L.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  11. #11
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,736
    PS: someone else alluded to it, but just to make sure, the "html" file that does the include of the PHP file must also be a .php file, or else that include won't be executed (the web server will not process the file as a PHP file).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  12. #12
    Join Date
    Dec 2015
    Posts
    8
    Yep, I needed to save the html file as a php file. I was thought I could do it as an Html file but i guess not. thanks for the help everyone.

  13. #13
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,736
    Technically, you could do it with a .html file, but you'd need to change your web server settings to add that file suffix (or specific file name) to the list of those that are to be processed as PHP. In this case, just changing the file name is probably better.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  14. #14
    Join Date
    Jan 2016
    Posts
    2
    Yes you can save it in .php format then it will be visible to you.

  15. #15
    Join Date
    Jan 2016
    Posts
    4
    Yes, first save file in .php format then it works.

    **** link removed by moderator - please do not spam this site ****
    Last edited by jedaisoul; 01-31-2016 at 11:25 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles