Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.