Jump to content

split HTML/PHP


angerbeaver

Recommended Posts

Hi,

 

I looked around the tutorials but didn't see anything (if I missed it, a link would be great;)) on how to split html/php code cleanly. The way I started to do it seemed good to me then I sat back and looked at my method and found it odd.

 

This is how I was doing it:

 

this was my include file:

 

<?
/* func.php */

function web_reg()
{
  echo '
            <form name"frmRegister" action="./" method="POST">
           <table border="0">
           <tr><td>Name:</td><td><input type="text" name="username" value=""></td></tr>
           <tr><td><input type="submit" value="Go"></d></tr>
           </table>
           <input type="hidden" name="action" value="register">
           </form>';
}

 

and the calling file

 

/* index.php */

<html>
<head><title></title>
<?php include('../func.php'); ?>
</head>
<body>
<?php
if(isset($_REQUEST['action']))
{
     if($_POST['action'] == "register")
     {
         /* register validation and user creation */
     }
     else
     {
         web_reg(); //Call to display the HTML
     }
}
?>
</body>
</html>

 

So I'm just wondering if using my index.php and calling a file to display the HTML is a weird/bad way of doing things.

Link to comment
https://forums.phpfreaks.com/topic/84195-split-htmlphp/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.