General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 30th, 2002, 11:42 AM
Vasarab69 Vasarab69 is offline
Goldmember
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 71 Vasarab69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 25 sec
Reputation Power: 6
Send a message via AIM to Vasarab69
Question a way to field all non existent variables?!?

lets say that i wanted to have a script that says so and so when the address is script.php?name=blah, or say something else when the script name is script.php?name=barf HOWEVER i, of course, want to prevent those 'curious' users from entering something bogus liike script.php?name=somethingtotallybogus...heres how i field all of the requests for existing variables:

PHP Code:
 $name $_POST["name"];
    
            if (
$name == "")
            
                
$name $_GET["name"];
                            
            if (
$name == "alex"// if the 'name' alex is input into the browser, it returns the following
        
                
{
        
                echo (
"<br><br>Hello Alex!");
            
                }
                
            if (
$name == "john")
        
                {
        
                echo (
"<br><br>Hey Johnny Boy!");
            
                } 


and that of course works fine...i also have some html in the beginning of the document so that if a user does not specify a variable it will default to that. i also have this code in the very beginning:

PHP Code:
if (empty($name))

{

// main page html here...




now what i would also like to do is either redirect users to the default page (with $name NOT specified) OR at least display an error stating that a the $name variable is either not specified, or the value is incorrect and therefor does not exist...heres how im currently doing this:

PHP Code:
elseif ( !$name )
            
            {
            
            echo (
"<br><br>You have entered an invalid name");
            
        } 
__________________
-Alexander

Reply With Quote
  #2  
Old December 2nd, 2002, 09:06 AM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
You'll have to store a list of valid names in either a database or a flat file and get the list of names each time the page loads, unless you want to enter each name manually. if you're not going to have a lot of names, that's not so bad..
PHP Code:
switch ($name) {
  case 
'johnny' : print 'Welcome Johnny'; break;
  case 
'alex'     : print 'Welcome Alex'; break;
  } 


Of course this gives you no flexibility, and I do suggest using some other method of storing your name list.

Reply With Quote
  #3  
Old December 2nd, 2002, 06:21 PM
Vasarab69 Vasarab69 is offline
Goldmember
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 71 Vasarab69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 25 sec
Reputation Power: 6
Send a message via AIM to Vasarab69
Question

alright thanks, but what other options have i got? i like your idea of having a mysql backend so i can do that easily, but how would i implement the scripting? would i , for instance, store in the column "name" of the db the name of the "person" and then in the, say, "content" column, store the html that would be displayed? thanks--

ps., when we have everything perfect and ready for publication and every thing, how would i make it so that if a "curious" user type in like name.php?name=blahblahblah, which doesn't exist, it would automatically display text stating to select a "person," and this would work for ANYTHING bogus? thanks--

Last edited by Vasarab69 : December 2nd, 2002 at 06:23 PM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > a way to field all non existent variables?!?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway