Computer Science Canada

Modules?

Author:  JHanson90 [ Sat May 15, 2004 11:53 pm ]
Post subject:  Modules?

I've seen URLs like this:
http://www.thedomain.com/?page=news
or http://www.thedomain.com/index.php?module=news

How are those pages made? And what are they? On one of the sites I've seen, the URL would be http://www.site.com/?page=news and it would take you to a page that has navigation menus, a banner, and a news article, and then I typed in http://www.site.com/?page=testingthispage and I got the same exact thing, except the place where the news article was just empty. What is that, and how do I do it?

Author:  Amailer [ Sun May 16, 2004 8:39 am ]
Post subject: 

that can be simply done by including a file if the $module = 'w/e';

code:

if($HTTP_GET_VARS['module'] == 'news') {
include('news.php');
}


and if you go to http://yoursite/index.php?module=news
it will display the information in the news.php

Author:  JHanson90 [ Sun May 16, 2004 5:02 pm ]
Post subject: 

Meh I'm such a noob; I should have figured that out myself :-\

Oh well, thanks a bunch Very Happy

Author:  JHanson90 [ Sun May 16, 2004 6:22 pm ]
Post subject: 

OK, what I did was have one page, called membersarea.php. I put this code in inside of it:
code:
<?php
                                                                        if($HTTP_GET_VARS['module'] == 'login') {
                                                                                include("loginset.php");
                                                                        } elseif ($HTTP_GET_VARS['module'] == 'membersarea') {
                                                                                include("membersareaset.php");
                                                                        } else {
                                                                                include("defaultset.php"); }
                                                                ?>
Then in 'membersareaset.php', the code was:
code:
<?php if($_POST['memberu'] == 'testuser' && $_POST['memberpass'] == 'testpass') { ?><table width="510" border="0" cellspacing="1" bgcolor="#000000">
      <tr>
        <td align="center" bgcolor="#000000">Welcome, <?php echo $_POST['memberu']; ?>.</td>
      </tr>
    </table>
        <?php } else { ?>
      <table width="510" border="0" cellpadding="8" cellspacing="1" bgcolor="#000000">
        <tr>
          <td align="center" bgcolor="#000000"><strong>WRONG!</strong><br>
          <br>
          Please try again, or stop trying to get into the Members' Only Area.</td>
        </tr>
      </table>
          <?php } ?>
Then inside of 'loginset.php', the code was:
code:
<td align="center" bgcolor="#000000"><strong><br>
            Members Area Login</strong><br>
            <form action="<?=$HTTP_GET_VARS['module']=='membersarea'?>" method="POST">
              <table width="250"  border="0" cellspacing="1" bgcolor="#000000">
                          <tbody>
                <tr>
                  <td align="right" bgcolor="#79715C">Username:</td>
                  <td align="center" bgcolor="#79715C"><input name="memberu" type="text" class="form2"></td>
                </tr>
                <tr>
                  <td align="right" bgcolor="#79715C">Password:</td>
                  <td align="center" bgcolor="#79715C"><input name="memberpass" type="password" class="form2"></td>
                </tr>
                <tr align="center">
                  <td bgcolor="#79715C" colspan="2"><input type="submit" class="formbutton" value="Enter }R{ Members Area">&nbsp;</td>
                </tr>
                                </tbody>
              </table>
            </form><br>
            </td>
OK, so in my MOZILLA browser I went to the /membersarea.php?module=login, then I input testuser and testpass and hit Enter, but all it did was refresh the page with the username and password fields blank. So then I tried it in my Internet Explorer browser. And instead of doing what MOZILLA did, the form didn't even show up. Everything was there except for the place where the form should go. I'm a noob...help?

Author:  Amailer [ Sun May 16, 2004 7:08 pm ]
Post subject: 

code:

<form action="<?=$HTTP_GET_VARS['module']=='membersarea'?>" method="POST">

is your problem, hmm what exactally are you doing there-- what you did there is.. set $HTTP_GET_VARS['module'] to membersarea.. when you had to do something like this..

code:

<form action="membersarea.php?module=membersarea" method="POST">


Wink

hope that helps

Author:  JHanson90 [ Sun May 16, 2004 7:39 pm ]
Post subject: 

Stupidity and ignorance is my strongest area.

I'm going to go eat myself.

I'm with stupid

Author:  Blade [ Thu May 27, 2004 5:39 pm ]
Post subject: 

Amailer wrote:
that can be simply done by including a file if the $module = 'w/e';

code:

if($HTTP_GET_VARS['module'] == 'news') {
include('news.php');
}


and if you go to http://yoursite/index.php?module=news
it will display the information in the news.php


wouldn't
code:
if($HTTP_GET_VARS['module']){
  include($HTTP_GET_VARS['module'] . ".php");
}

be better? ... if he is programmin his own site, then he should know which parameters to put in the links and stuff... this is more dynamic than having 1500 if statements.

Author:  Amailer [ Thu May 27, 2004 7:02 pm ]
Post subject: 

yes, hmm very true Embarassed
*walks away*


: