SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Navigation Question?

    Hi Guys,

    i have noticed on quite a few different sites, the navigation is like this:

    /index.php?page=home Or /index.php?page=contact etc, instead of home.php or contact.php

    can anyone tell me what the advantages (if any) to using the first way as opposed to the second (which i usually do)

    Thanks guys

    Graham

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2006
    Location
    Newcastle, England
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Graham,

    if i'm reading you right - the first way is using the URL to pass a value (usually refered to as a name value pair).

    So, if you want a page to open and do something different depending on a value, you can use the URL to pass this value.

    i.e. Above the '/index.php?page=home' link is passing the value 'home' using the variable (name) 'page'.
    So, index.php can use a $_GET['page'] command to retrieve the value (in the first instance, 'home') and then determine what to do.

    If, as in the second case the value is 'contact' it can do something different.

    My guess is the pages your talking about use the same page to display different content (depending on the value passed).

    Hope this helps

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jackel, I think he understand that. I believe he's asking about the benefits of doing it that way?

    graham:

    As far as I know theres no real benefit of using this method.

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    theJackel described it well.

    index.php is the only file and it seemingly handles all the other content.

  5. #5
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All it does is that it allows your pages be dynamic.
    So, for example, on your contact.php page if you had a drop down menu for the subject of the "send message" form like

    Customer Service
    Hot Secretary
    Always annoyed IT guy
    Condescending Macs-are-better guy

    Then your could conceivably, have different links on your site like

    contact.php?who=customer_serv
    contact.php?who=hot_sec
    contact.php?who=it_guy
    contact.php?who=mac_dude

    and then on the contact.php page you could do a
    switch statement on $_GET['who'] and preselect a subject based on the url.

    So your contact.php page becomes dynamic (based on the url values)


    Quote Originally Posted by graham23s View Post
    Hi Guys,

    i have noticed on quite a few different sites, the navigation is like this:

    /index.php?page=home Or /index.php?page=contact etc, instead of home.php or contact.php

    can anyone tell me what the advantages (if any) to using the first way as opposed to the second (which i usually do)

    Thanks guys

    Graham

  6. #6
    SitePoint Addict silentcollision's Avatar
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do it because it means less files, and because it looks cool =/

  7. #7
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Btw search engines are wary of those kind of urls, so if you have to use them, then use Apache mod rewrites to make
    _ww.dundermifflinpaperco.com/contact.php?who=hot_secretary&why=ask_for_date&possibility_success=0
    into
    _ww.dundermifflinpaperco.com/contact/hot_secretary/ask_for_date/0

    Quote Originally Posted by silentcollision View Post
    I do it because it means less files, and because it looks cool =/

  8. #8
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the advice guys, i always wondered what was the reason, just really personal preference in the end

    cheers

    Graham

  9. #9
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Updating Database Through PHP

    Hi Guys,

    i have successfully made a form which displays a users details ready for them to edit and re-submit the changes:

    PHP Code:
    <p align="left">Welcome, <b><font color="red"><? echo $_COOKIE['member'?></font></b>! (<a href="logout.php">Logout</a>) - [ <a href="change_password.php">Change Password Or E-mail Address</a> ] - [ <a href="edit_profile.php">Edit Profile</a> ] - [ <a href="upload_photo.php">Upload Photo</a> ]</p>
    <?php
         
    // Start retrieving user profile from database//////////////////////////////////////
        
    $qProfile "select * from membership where username='$member'";
        
    $rsProfile mysql_query($qProfile);

        
    $row mysql_fetch_array($rsProfile); // get the resultset into an array/////////////
        
    extract($row); // extract the resultset

        // Now print the form, in HTML format with php thrown in/////////////////////////////
    ?>
    <p>Edit Your Profile Details<p>
    <p><form action="edit_profile_done.php" method="post"> 
       <table width="400" border="0" bordercolor="black" cellspacing="2" cellpadding="2">
         <tr>
          <td align="right" bgcolor="#E2E2E2">Your E-Mail<td>
         <td bgcolor="#E2E2E2"><input name="email" type="text" id="name" maxlength="30" size="25" value="<?php echo "$email"?>"></td>
         </tr>
         <tr>
          <td align="right" bgcolor="#E2E2E2">Your Occupation:</td>
         <td bgcolor="#E2E2E2"><input name="occupation" type="text" id="name" maxlength="30" size="25" value="<?php echo "$occupation"?>"></td>
         </tr>
         <tr>
          <td align="right" bgcolor="#E2E2E2">Your Description:</td>
         <td bgcolor="#E2E2E2"><textarea name="description" rows="20" cols="25"><?php echo "$description"?></textarea></td>
         </tr>
         <tr>
          <td align="right" bgcolor="#E2E2E2">Your Countrytd>
         <td bgcolor="#E2E2E2"><textarea name="country" rows="20" cols="25"><?php echo "$country"?></textarea></td>
         </tr>
         <tr>
          <td bgcolor="#E2E2E2">&nbsp;</td><input type="hidden" name="username" value="<?php echo "$username"?>" >
         <td bgcolor="#E2E2E2"><input type="submit" name="Submit" value="Update Profile!"></td>
         </table>
    This is the code i used for updating:

    PHP Code:
    <?php
         
    // Start of Update Code

         // For register_global on PHP settings
        
    $username mysql_escape_string($_POST['username']);
        
    $email mysql_escape_string($_POST['email']);
        
    $occupation mysql_escape_string($_POST['occupation']);
        
    $description mysql_escape_string($_POST['description']);
        
    $country mysql_escape_string($_POST['country']);

        
    // Update Database put the variables in a query
        
    $query "UPDATE membership SET email='$email' ";
        
    $query .= " WHERE username='$username',occupation='$occupation',description='$description',country='$country'";
        
    $result mysql_query($query);

        if (
    $result)
        {
         echo 
    "<p>Thank you. Your profile has been updated.</p>";
    }
    ?>
    only the very first field (username for testing purposes) seems to update successfully, the minute i add:

    PHP Code:
    occupation='$occupation' 
    or the other 3 fields it doesn't seem to update it, only the first field updates

    Thanks for your help guys it's appreciated

    Graham

  10. #10
    SitePoint Zealot
    Join Date
    Aug 2006
    Location
    Newcastle, England
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm,

    PHP Code:
    $query "UPDATE membership SET email='$email' ";
    $query .= " WHERE username='$username',occupation='$occupation',description='$description',country='$country'"
    seems to be wrong. Try:

    PHP Code:
    $query "UPDATE membership SET email='$email', username='$username',occupation='$occupation',description='$description',country='$country'";
    $query .= " WHERE username='$_COOKIE['member']'"
    Your query is just updating the email I think.

  11. #11
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    US
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I prefer the second one, because it much more Search Engine friendly.
    The first one may include all webpages in one php script.
    My suggestion is never use the first one.

  12. #12
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all the replies and input, i am going to stick twith the first one i think cos it's the easiest for em at the minute lol, thanks also Jackel that code was what i was after

    thanks again

    Graham


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •