Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Modules?
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JHanson90




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Amailer




PostPosted: Sun May 16, 2004 8:39 am   Post subject: (No 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
JHanson90




PostPosted: Sun May 16, 2004 5:02 pm   Post subject: (No subject)

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

Oh well, thanks a bunch Very Happy
JHanson90




PostPosted: Sun May 16, 2004 6:22 pm   Post subject: (No 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?
Amailer




PostPosted: Sun May 16, 2004 7:08 pm   Post subject: (No 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
JHanson90




PostPosted: Sun May 16, 2004 7:39 pm   Post subject: (No subject)

Stupidity and ignorance is my strongest area.

I'm going to go eat myself.

I'm with stupid
Blade




PostPosted: Thu May 27, 2004 5:39 pm   Post subject: (No 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.
Amailer




PostPosted: Thu May 27, 2004 7:02 pm   Post subject: (No subject)

yes, hmm very true Embarassed
*walks away*
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: