HTML and PHP in one file



PHP Snippet 1:

OR you can put 2 different pages that act as 1 by using INCLUDE FUNCTION


script1.php
<form action="script2.php" method="post" name="myform">
    ...
    <input type="submit" name='submit_button' value="Submit" />
<input
</form>

---------------
script2.php

include 'script1.php';

if(isset($_POST['submit_button']
{.......}

PHP Snippet 2:

<?php echo htmlspecialchars ($_SERVER["PHP_SELF"]);?>

PHP Snippet 3:

<?php
if(isset($_POST['btnsubmit'])) {
    // Do your Operation here...
}
?>
<form action="script.php" method="post" name="myform">
    ...
    <input type="submit" name="btnsubmit" value="Submit" />
<input
</form>

PHP Snippet 4:

 header( 'Location: ' . $_SERVER['HTTP_REFERER'] ); // Refer to the last page user was on...

PHP Snippet 5:

header( 'Location: http://some.url/' );

PHP Snippet 6:

<?php
        if(isset($_POST)){

        //do your php work here

       }
?>


<html>
<form method='POST'>
   //form elements here
   <input type='submit'>
</form>
<!-- other html code -->
</html>