Welcome Guest, Not a member yet? Register   Sign In
How can I secure this little.
#1

[eluser]phantom-a[/eluser]
I created a redirection. Basically they click on the link on my Directory script I'm creating and it looks like this.

http://example.com/index.php/go/hits/1

Where the 1 on the end of hits is the ID used in the Mysql query to find the corresponding url the script loads view/redirect_url.php where I put print the url in a javascript redirect.

But what if that number doesn't exist?? What if someone puts some numbers on by purpsoe or puts letters on it? Right now it will show a blank page. I would like to show a 404 not found. This my code, how can make an if statement that checks the ID in the query so that if the ID doesn't exist it would echo a not found error?

Code:
function hits()
    {
    
     $data['title'] = "Redirection..";
     $data['heading'] = "Prepare to be redirected to...";
//Get the URL from the ID
     $data['query'] = $this->db->query('SELECT `url` FROM `links` WHERE `id`='.$this->uri->segment(3).'');
     //update hits
     $this->db->query('UPDATE `links` SET `hits`=hits+1  WHERE `id`='.$this->uri->segment(3).'');
     $this->load->view('redirect_url', $data); // this go to a page there redirects by javascript with the url.
    }


Messages In This Thread
How can I secure this little. - by El Forum - 09-07-2008, 08:37 PM
How can I secure this little. - by El Forum - 09-07-2008, 09:23 PM
How can I secure this little. - by El Forum - 09-07-2008, 11:30 PM
How can I secure this little. - by El Forum - 09-08-2008, 12:09 AM
How can I secure this little. - by El Forum - 09-08-2008, 12:39 AM
How can I secure this little. - by El Forum - 09-08-2008, 12:55 AM
How can I secure this little. - by El Forum - 09-08-2008, 01:09 AM
How can I secure this little. - by El Forum - 09-08-2008, 02:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB