CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 RESOLVED- Redirect if URL value not present

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 05/18/2009, 12:53 PM

On this forum, the threads are filtered by the url "forum_id".

When I remove this from the URL window, it redirects me to the main page.. which is great.
What is the code that does this?

Right now, on the page/grid I created, if you remove the Urlit just shows ALL records.


Is there a CCS way of doing this that I am missing or is this in the Events code?
Thanks!

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
melvyn


Posts: 333
Posted: 05/18/2009, 4:11 PM

Event After Initialize:

  
if (!isset($_GET['post_id'])){  
   global $Redirect;  
   $Redirect = "index.php";  
}  

_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
ckroon

Posts: 869
Posted: 05/19/2009, 10:16 AM

Thanks Melvyn.. that works if the users takes away teh URL completely but if they remove the integer...
change it from

forumid=1

to

forumid=

It still displays all the records and doesnt redirect..
I tried this:

if
(CCGetFromGet("forumid","") < 0 ){ global $Redirect; $Redirect = "mainboard1.php";}

But it doesn't do anything :)


_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
melvyn


Posts: 333
Posted: 05/19/2009, 10:55 AM

I gave the general idea.
Try this:
if ( (!isset($_GET['post_id']))&&($_GET['post_id']>0 )){    
   global $Redirect;    
   $Redirect = "index.php";    
}

The above will check two conditions:
1) post_id is in the url
2) post_id has a value greater than zero.

Both must match. If not, will redirect.

Anyways, that doesn't know if the value in the url is a correct value.

Also don't work when the variable value is an string.

For string variables try this
if ( (!isset($_GET['post_id'])) && (strlen($_GET['post_id'])>0) ){    
   global $Redirect;    
   $Redirect = "index.php";    
}

The above will check it receives a value in post_id and that value must have at least one character (string or numeric).


_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
damian

Posts: 838
Posted: 05/19/2009, 5:49 PM

check in your VQB - you can set a default value...
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
asongo


Posts: 19
Posted: 05/19/2009, 6:08 PM

global $Redirect;   
   if(CCGetParam("post_id","") == "") {  
   $Redirect = "index.php";   
   }

_________________
PHP 4.4x ,MySQL 4.0x
Kaohsiung,Taiwan
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.