Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] PHP URL VARABLES? Please Help!!!


PHP URL VARABLES? Please Help!!!

Closed Thread
  #1 (permalink)  
Old 12-27-09, 10:49 AM
hunterhdolan hunterhdolan is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 30
Thanks: 5
Thanked 0 Times in 0 Posts
Exclamation PHP URL VARABLES? Please Help!!!

Ok so I am designing a script and I need to display a message when a person clicks a link.

How can I get php to reconize

index.php?message=1

then say success.

and

index.php?message=2

then say Error

Above the content.

but not show ether when it is just index.php

I know it can be done but I just can't figure it out. Thanks for your help.
__________________
I was laying in bed last night looking at the stars..... Then it occurred to me. Where the hell is the ceiling!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #2 (permalink)  
Old 12-27-09, 12:17 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
What you'll need to do is check the content of the variable "$message" and display the appropriate message based on what it contains. Here's a simplified example, untested, but should work. Place this at or near the top of your index.php file:

PHP Code:

$message preg_replace("/[^0-9]/"''$_GET['message']);


if(
$message == '1'){
   print 
'Success';
}elseif(
$message == '2'){
   print 
'Error';


Quote:
Originally Posted by hunterhdolan View Post
Ok so I am designing a script and I need to display a message when a person clicks a link.
How can I get php to reconize
index.php?message=1
then say success.
and
index.php?message=2
then say Error
Above the content.
but not show ether when it is just index.php
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
The Following User Says Thank You to End User For This Useful Post:
hunterhdolan (01-17-10)
  #3 (permalink)  
Old 12-27-09, 07:16 PM
hunterhdolan hunterhdolan is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 30
Thanks: 5
Thanked 0 Times in 0 Posts
Spin Thanks

Quote:
Originally Posted by End User View Post
What you'll need to do is check the content of the variable "$message" and display the appropriate message based on what it contains. Here's a simplified example, untested, but should work. Place this at or near the top of your index.php file:

PHP Code:

$message preg_replace("/[^0-9]/"''$_GET['message']);


if(
$message == '1'){
   print 
'Success';
}elseif(
$message == '2'){
   print 
'Error';

Thank You So Much! It worked!!! I can even put HTML in there!
__________________
I was laying in bed last night looking at the stars..... Then it occurred to me. Where the hell is the ceiling!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #4 (permalink)  
Old 12-27-09, 08:46 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by hunterhdolan View Post
Thank You So Much! It worked!!! I can even put HTML in there!
Glad I could help.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #5 (permalink)  
Old 12-28-09, 12:50 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
Just for reference this called the GET method ... you can Google some more info just search for HTML form GET
__________________
This post was created with 100% recycled electrons.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Closed Thread

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP or PHP which is better? nepala The Lounge 9 07-14-10 06:48 AM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
How to get currentl url in addrss bar via php? method PHP 3 02-26-07 04:21 AM
get URL from iframe in PHP? nassau PHP 4 01-21-05 01:48 AM
Php casestatement URL blessedrub JavaScript 1 01-12-05 09:12 PM


All times are GMT -5. The time now is 04:46 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.