There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware network networking nvidia outlook outlook 2003 outlook express partition printer problem ram router slow sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: PHP Help :)


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Xperience's Avatar
Computer Specs
Senior Member with 136 posts.
 
Join Date: Feb 2007
Location: Australia
Experience: Microsoft Desktop Support Technician
25-Feb-2007, 12:21 AM #1
Solved: PHP Help :)
Hi!

Need some PHP help here. You know, in PHP how the URL can sometimes go:

http://somesite.com/index.php?act=something

Okay, so what i want to know is how to make the "act" at the end of the "index.php?". So just say when a user clicked http://somesite.com/index.php?act=contact it would take them to our contact page.

Okay, so how do i code it in the index.php file to tell it to go to our contact page when the user clicks http://somesite.com/index.php?act=contact ??

I think its better like this, so instead of http://somesite.com/contact.php its http://somesite.com/index.php?act=contact

How can i do this? Thanks in advance!
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
25-Feb-2007, 12:28 AM #2
PHP Code:
switch($_GET['act'])
{
  case 
'contact':
    require_once(
'contact.php');
    break;
  default:
    require_once(
'index.php');
}
?> 
Xperience's Avatar
Computer Specs
Senior Member with 136 posts.
 
Join Date: Feb 2007
Location: Australia
Experience: Microsoft Desktop Support Technician
25-Feb-2007, 01:05 AM #3
thanks. but is there anyway i can point it to a file in another directory?

E.g. directory name is contact and the file in the contact directory is index.php
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
25-Feb-2007, 01:09 AM #4
require_once('contact/index.php');
Xperience's Avatar
Computer Specs
Senior Member with 136 posts.
 
Join Date: Feb 2007
Location: Australia
Experience: Microsoft Desktop Support Technician
25-Feb-2007, 01:12 AM #5
okay it works, except the page that i wanted it to go to shares the screen with the root index.php
Xperience's Avatar
Computer Specs
Senior Member with 136 posts.
 
Join Date: Feb 2007
Location: Australia
Experience: Microsoft Desktop Support Technician
25-Feb-2007, 01:31 AM #6
Doesnt matter. I used if else statements to call a function. Thanks for your help!!! Really appreciated.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,250 posts.
 
Join Date: Oct 2006
25-Feb-2007, 02:56 AM #7
Thanks, I too wanted to know how to do this.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,250 posts.
 
Join Date: Oct 2006
25-Feb-2007, 09:25 AM #8
How about if you want the contact file inside index.php, can you still make it do that?
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,197 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
25-Feb-2007, 09:33 AM #9
Quote:
Originally Posted by MMJ
How about if you want the contact file inside index.php, can you still make it do that?

PHP Code:
switch($_GET['act']) {

case 
'contact':
echo 
'The info directly in the index.php file'
break;

 default:
//What you want to show up by default when 'act' doesn't equal any of your cases


namenotfound's Avatar
Computer Specs
Distinguished Member with 2,197 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
25-Feb-2007, 09:36 AM #10
Quote:
Originally Posted by MMJ
Thanks, I too wanted to know how to do this.
lol you're as bad as knight not seeing the highlight thing

I posted this months ago on Xen
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,250 posts.
 
Join Date: Oct 2006
25-Feb-2007, 10:00 AM #11
Quote:
Originally Posted by namenotfound
lol you're as bad as knight not seeing the highlight thing

I posted this months ago on Xen
Well you should have put a link to it in your sig.

Thanks.
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,197 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
25-Feb-2007, 01:01 PM #12
Remember the site I had that got deleted by harmor's old host? Yeah well it was right there (which I had linked in my sig before it got deleted). The site that listed all my tutorials

I'll eventually put it back up on another site.

I'm glad harmor got a new host, his old one sucked. Randomly deleting sites and stuff.
__________________
-----------------------------
| 404: Name Not Found |
-----------------------------
PLEASE NOTE: If I happen to help you in a post, or just simply reply to it, doesn't mean I want to be bombarded with PMs. I answer all questions in posts, not in PMs. Thank you, and have a good day.

<?php $h = 'Hello '; $w = 'World'; echo $h.$w; ?>

My Favorite Editors:
Windows: Crimson Editor
Mac: Taco HTML Edit
Linux: gPHPEdit
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:41 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.