PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Below I have a basic php file that displays a form if 'submit' is not set. I have the html file by itself and bring it in using file_get_contents, but the $PHP_SELF within that HTML file does not seem to work. Why?
<?
extract($_Post);
if (!isset($submit)) { //if the form has NOT been submitted, show the following HTML
echo file_get_contents('donate_form.html');
} else { //if it HAS been submitted, give them text
//email variables and POST again
}
?>
//donate_form.html (below)
<html>
html...
<form id="FormName" action="<?=$PHP_SELF?>" method="POST" name="FormName">
html...
</form>
</html>
But if I use include(), then I will need to escape all quotes. Correct? Also wouldn't I need to assign the HTML to a variable and then return(variable)??
no, the webserver will only parse as php blocks between <? and ?> or <?php and ?> if short open tags is off.
so you don't need to escape any quotes that are not inside those tags
Right, but the include is between PHP blocks in the main file. When I submit now, it returns me back to the page, also has a "1" at the bottom of the form.
<?
#good bye extract
if (!isset($_POST['submit'])) {
include('donate_form.html');
} else { //if it HAS been submitted, give them text
//email variables and POST again
}
?>
//donate_form.html (below)
<html>
<form id="FormName" action="<?echo $_SERVER['PHP_SELF'];?>" method="POST" name="FormName">
</form>
</html>