Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 07-01-09   #1 (permalink)
4.0ghz
 
Chopes's Avatar
 
amd nvidia

Join Date: Jul 2005
Location: Maryland
Posts: 5,081

Rep: 287 Chopes is a proven memberChopes is a proven memberChopes is a proven member
Unique Rep: 196
FAQs Submitted: 18
Folding Team Rank: 904
Trader Rating: 11
Default PHP Url Check Script Help?

Hey,

I am trying to write a simple script in which "Hello world" is echoed back if the url contains index.php?option=A else "POOP" is echoed back.

Obviously I am not going to be using "hello world" or "poop" but I am not exactly a beginer with php, but for some reason I am completely stumped when trying to write this? Can anyone offer assistance?

For further clarification on what I am trying to do, when I check if it contains index.php?option=A there will be other stuff after the A that will be changing, but index.php?option=A will be constant. Example: index.php?option=A&setting2=B.

I don't care about setting2 as long as option=A in the url. I hope this makes enough sense for someone to offer help. I know the script isn't longer then 6-7 lines, I am just stumped on how to query the url and use it like I am intending.

Again, any help is much appreciated.
__________________

System: FX-57 Rig
CPU
AMD Athlon64 FX-57
Motherboard
DFI Lanparty NF4 SLI-DR
Memory
OCZ 2x1 GB 2-3-2-5
Graphics Card
EVGA 7950GX2
Hard Drive
74GB Raptor
Sound Card
Creative Audigy 2
Power Supply
680W Aspire
Case
Thermaltake Armor
CPU cooling
Apogee Waterblock
GPU cooling
Air
OS
Windows Vista Ultimate
Monitor
Acer AL2216W 22" Widescreen
Chopes is offline I fold for Overclock.net Overclocked Account Chopes's Gallery   Reply With Quote
Old 07-01-09   #2 (permalink)
First Time Build
 
intel nvidia

Join Date: Feb 2006
Location: pa usa!
Posts: 1,765

Rep: 63 uberjon is acknowledged by some
Unique Rep: 53
Folding Team Rank: 1544
Trader Rating: 0
Default

are you getting the URL from post/get? or are you assuming it because of the file its accessing?

if the second,

Code:
filename = index.php
<?php
if($_GET['option'] !='A')
{
echo "poop";
}else{
echo "hello world!";
}
?>
__________________
8800GT FTW
Quote:
Originally Posted by DontPassTheFence View Post
Holds true to today, I'm 21 and still a punk kid at heart XD (but Im packing broadband now, woo hoo dL`in pr0nz up to 49877489187327 times faster)
^ best quote ever!!! ^

System: to big yet not big enough
CPU
e6600 stock/3ghz
Motherboard
asus p5b deluxe
Memory
ddr2-800 xms2 2x2GB + 2x1GB
Graphics Card
evga 8800gt 512MB
Hard Drive
perc5i 4x 36GB 15k SAS raid0
Sound Card
razer ac-1
Power Supply
750 watt silencer
Case
mozartTx
CPU cooling
infinity
GPU cooling
stock
OS
vista 64bit
Monitor
22 inch ws proview lcd (love it)
uberjon is offline I fold for Overclock.net   Reply With Quote
Old 07-01-09   #3 (permalink)
4.0ghz
 
Chopes's Avatar
 
amd nvidia

Join Date: Jul 2005
Location: Maryland
Posts: 5,081

Rep: 287 Chopes is a proven memberChopes is a proven memberChopes is a proven member
Unique Rep: 196
FAQs Submitted: 18
Folding Team Rank: 904
Trader Rating: 11
Default

I am trying to get the current page url and check that. Is that what was assumed in post #2? Also does this work if theres more then 1 option? IE. option=A&test=B&randolph=G
__________________

System: FX-57 Rig
CPU
AMD Athlon64 FX-57
Motherboard
DFI Lanparty NF4 SLI-DR
Memory
OCZ 2x1 GB 2-3-2-5
Graphics Card
EVGA 7950GX2
Hard Drive
74GB Raptor
Sound Card
Creative Audigy 2
Power Supply
680W Aspire
Case
Thermaltake Armor
CPU cooling
Apogee Waterblock
GPU cooling
Air
OS
Windows Vista Ultimate
Monitor
Acer AL2216W 22" Widescreen

Last edited by Chopes : 07-01-09 at 08:07 PM
Chopes is offline I fold for Overclock.net Overclocked Account Chopes's Gallery   Reply With Quote
Old 07-01-09   #4 (permalink)
Ding ding ding ding ding!
 
afzsom's Avatar
 
intel nvidia

Join Date: Jun 2007
Location: Boca, FL
Posts: 4,806

Rep: 664 afzsom is becoming famousafzsom is becoming famousafzsom is becoming famousafzsom is becoming famousafzsom is becoming famousafzsom is becoming famous
Unique Rep: 403
Trader Rating: 8
Default

Yes, what the script will do is check each variable in the get query string.

So you have option=A, test=B, randolph=G. $_GET['option'] is for whatever is after the option, $_GET['test'] is for whatever is after test, and so on.

The $_GET is what grabs information from the URL, however the $_POST usually comes from a submitted form. So your code could look like:

Code:
<?php
if ($_GET['option'] == 'A') {
  echo "hello world!";
}
if ($_GET['option'] == 'A' && $_GET['test'] == 'B') {
  echo "Hello world, testing for B.";
}
?>
And so on
__________________
Watercooling Loop: MCP655 Vario -> Black Ice GTX360 -> Stinger Diamond Max -> Heatkiller GPU-X² -> MicroRes


System: R'lyeh
CPU
Q9550 (4.03GHz)
Motherboard
Gigabyte EP45-UD3P
Memory
4GB (2x2) Corsair Dominator (5-5-5-15, 2.1v)
Graphics Card
EVGA GTX285
Hard Drive
300GB WD VelociRaptor, 320GB WD Caviar 7200
Sound Card
Auzentech X-Fi Forte 7.1
Power Supply
Corsair HX750W
Case
Lian-Li V2000
CPU cooling
Stinger Diamond Max
GPU cooling
Heatkiller GPU-X² GTX285 Rev. 2
OS
Vista Home Premium x64
Monitor
Samsung 226BW
afzsom is offline Overclocked Account afzsom's Gallery   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 03:29 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.10478 seconds with 8 queries