Results 1 to 7 of 7
  1. #1
    Murdock69's Avatar
    Join Date
    Nov 2014
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    0

    Running HTML in a .PHP file

    Hi guys I was working on a landing page and it required me to copy and paste all of my HTML code into a .php file. The code works and runs fine in HTML but as soon as it's copy-pasted into the PHP file none of the buttons or really anything work even when tested in the browser. Any help would be appreciated, I can provide the link to a pastebin of the .php file if needed.

  2. #2
    Kain1's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    /r/winterfell
    Posts
    1
    Reputation
    10
    Thanks
    2
    My Mood
    Crappy
    The browser can read HTML differently than PHP does, for example paths to required files like CSS, JS, etc... Providing the pastebin would be great.

  3. #3
    Murdock69's Avatar
    Join Date
    Nov 2014
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    0
    I figured out the problem with it, it wasn't necessarily the PHP it was a user error.

  4. #4
    Maze.'s Avatar
    Join Date
    Nov 2015
    Gender
    male
    Location
    USA
    Posts
    42
    Reputation
    10
    Thanks
    4
    Note to beginners, never forget to redirect the style sheets when moving into new directories.

  5. #5
    Yetee's Avatar
    Join Date
    Dec 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    Do you have the HTML within the <?php ~php code~ ?> ?

  6. #6
    volt23's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    16
    Reputation
    10
    Thanks
    0
    U can ask for free email help from local webstudio in your area, they usually are welcome to help, so u can try it if the problem is still actual.

  7. #7
    kchoman's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    20
    Reputation
    10
    Thanks
    6
    Here's how you handle form data when you're not putting HTML in a PHP file:
    Code:
    <form action="confirm.php" method="post">
        <input type="submit" id="formButton" value="Submit" />
    </form>
    Here's how you handle form data when you're putting HTML in a PHP file:
    Code:
    <?php
    
    if(filter_has_var(INPUT_POST, 'formSubmission')) {
        //TODO: Something with the form data...
    }
    
    ?>
    <form method="post">
        <input type="submit" id="formButton" name="formSubmission" value="Submit" />
    </form>
    Since the PHP will be loading with the HTML data, we don't want to automatically manage form data before the visitor can put anything in the form.
    Plus don't forget to filter your inputs; it's just bad practice to call superglobal variables directly.

    Code:
    /** @Info: Simple non-regex email address filter. */
    if(filter_input(INPUT_POST, 'emailAddress', FILTER_VALIDATE_EMAIL)) {
        //TODO: Success
    } else {
        //TODO: Failure
    }

Similar Threads

  1. Dispatching a request through a php file
    By toby2449 in forum Realm of the Mad God Private Servers Help
    Replies: 0
    Last Post: 04-21-2015, 02:26 PM
  2. [Help] How To View A Websites Index.php File
    By Jim Morrison in forum Exploits
    Replies: 12
    Last Post: 02-18-2014, 06:18 PM
  3. [Help Request] Unable to run game due to client file being corrupted
    By final-legacy in forum Combat Arms Mod Help
    Replies: 1
    Last Post: 07-25-2013, 09:16 AM
  4. php file upload type restriction
    By franzyx in forum PHP Programming
    Replies: 5
    Last Post: 04-21-2012, 08:52 PM
  5. Selling Phising files [Php & Mysql]
    By niek123 in forum Trade Accounts/Keys/Items
    Replies: 7
    Last Post: 03-27-2008, 11:27 AM