Is it a good way of programming?

Discussion in 'PHP' started by asmon, Jul 23, 2008.

  1. #1
    for example i have a page with the following conditions
    if (isset($team))
    {}
    elseif (isset($request))
    {}
    elseif (isset($admin))
    {}
    else
    {}

    now each statement includes many forms and when each form is clicked
    there's a long php code. if i create everything in one file it's going to be
    a big mess.
    what i'm doing is something like this

    if (isset($team))
    {
    form1
    form2
    form3
    require('pagename.team.php');
    }
    elseif (isset($request))
    {
    form1
    form2
    form3
    require('pagename.request.php');
    }
    elseif (isset($admin))
    {
    form1
    form2
    form3
    require('pagename.admin.php');
    }
    else
    {
    form1
    form2
    form3
    require('pagename.noteam.php');
    }

    inside the required php pages i put everything which is being executed
    when the relevant forms are submitted. if (isset($_post['form1'])) ....

    my question is, is this a good thing to do or it can cause some issues
    or maybe it's just stupid for another reason? ty.
     
    asmon, Jul 23, 2008 IP
  2. Mozzart

    Mozzart Peon

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, I don't see anything wrong at the moment but you might want to use smarty or other template engine. Such a redundancy will eventually drive you nuts.

    It's something like if(isset($_POST['submit']))
     
    Mozzart, Jul 23, 2008 IP
  3. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    i actually have no idea what template engines are....
    i only understand the basic idea of separating html from php
     
    asmon, Jul 23, 2008 IP