Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2005, 01:52 AM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default QueryString Problem

Maybe someone can help me with a small problem.

In perl you are able to say something to the effect of:

Code:
 } elsif ($ENV{'QUERY_STRING'} =~ /admin/i) { &admin;
 }


to see if part of the query string contains "admin" in the string, if it does, goto sub admin.

Well in php I want to do the same thing.

The code I'm currently using is similar to:
Code:
elseif ($_SERVER['QUERY_STRING'] == "validate"){ConfirmEmail();}
which works fine if the url is http://mysite/index.php?validate

but in reality, that will never be the url, anything hitting that url will be more like http://mysite/index.php?validate=ksjdfjhsdfjkhsjkfh

and when I use that URL it doesn't catch it and just sends it to the default function because at the bottom of the elseifs is:
Code:
else {ind();}
I realize that its because I have "==" in the statement, but is there a function similar to the perl "=~" so that I can just see if the query string contains "validate" instead of people exactly "validate"

Any help would be greatly appreciated.
 
Old January 10th, 2005, 02:30 PM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never mind, figured it out:

elseif (preg_match("/validate=/", $_SERVER['QUERY_STRING'])){ConfirmEmail();}

 
Old January 10th, 2005, 07:59 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

For a faster result try

if(isset($_GET['validate']))
{
  do_something();
}

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old January 10th, 2005, 08:06 PM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep, I'd say thats a faster solution. Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Querystring Problem kaustic Beginning PHP 1 May 16th, 2007 07:47 AM
Problem with QueryString in ASP s.abraham ASP.NET 1.0 and 1.1 Basics 1 March 22nd, 2005 04:43 PM
Problem with Request.QueryString mg1966 Classic ASP Databases 4 January 7th, 2005 02:04 PM
querystring problem -Dman100- Classic ASP Professional 10 September 15th, 2004 09:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.