How to fetch unconsistant values from URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gimpact
Forum Commoner
Posts: 65
Joined: Tue Jun 16, 2009 11:08 pm

How to fetch unconsistant values from URL

Post by gimpact »

Hi,

I have an email application in my site. When the users click on compose mail. I show them a ajax enabled form, they select the email id (To:) and continue by clicking on a "Email now" link. "Email now" generates an url of the form

Code: Select all

 
http://www.domain.com/?ulr=MailBox.compose&message=b273424cb7570c86b1bc8f0a53544c53
 
Here, the "message" is actually a MD5 of the (To:) email id. In the index.php page at http://www.domain.com/index.php I have this code

Code: Select all

 
$url = $_REQUEST['url'];
$message = $_REQUEST['message'];
 
if ($ulr == 'Home'){
     require ("webpages/html/home.php");
}else if ($url == 'AboutUs'){
     require ("webpages/html/contactus.php");
}else if ( ($url == 'MailBox') && ( $message == ''){
     require ("mail/compose/compose_new.php");
}else{
     require ("webpages/html/home.php");
}
 
Now the issue is the $message value keep changing, does any one know how to make sure that what ever be here

Code: Select all

 
http://www.domain.com/?ulr=MailBox.compose&message=b273424cb7570c86b1bc8f0a53544c53
 
it should always fetch

Code: Select all

require ("mail/compose/compose_new.php");
Thank you very much
User avatar
BlaineSch
Forum Commoner
Posts: 28
Joined: Sun Jun 07, 2009 4:28 pm
Location: Trapped in my own little world.

Re: How to fetch unconsistant values from URL

Post by BlaineSch »

If you know it's GET/POST you should not use REQUEST.

You could simply do

Code: Select all

if(strlen($_GET['message']) >= 1) {
require ("mail/compose/compose_new.php");
}
gimpact
Forum Commoner
Posts: 65
Joined: Tue Jun 16, 2009 11:08 pm

Re: How to fetch unconsistant values from URL

Post by gimpact »

Thank you, i got your logic.
Post Reply