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

[eluser]phantom-a[/eluser]
Once again Frank thanks Smile
Your method didn't not work, it threw parse error, unexpected T_VARIABLE on the line
Code:
if (is_int($this->uri->segment(3)) $data['query'] = $this->db->query('SELECT `url` FROM `links` WHERE `id`='.intval($this->uri->segment(3)).''); // only execute if the id is an int


But I didn't know about intval() and I"m always up for learning about the Variable handling Functions. This was great you mentioned this. So Thought of just passing the segment ID into it first then pass it into the query as you see my code,
this which works now 100%. Smile
Code:
$data['title'] = "Redirection..";
     $data['heading'] = "Prepare to be redirected to...";
     $URL_ID = intval($this->uri->segment(3)); //Turn into integers so no wankers try to pass letters into the query
     $data['query'] = $this->db->query('SELECT `url` FROM `links` WHERE `id`='.mysql_real_escape_string($URL_ID).'');
     if ($data['query']->num_rows() != 1) { // check if we have exactly one result

        header("HTTP/1.0 404 Not Found",true); // wanna be nice
        echo '404 not found';  // optional
        die; // get outta here
     }
    
    

     $this->db->query('UPDATE `links` SET `hits`=hits+1  WHERE `id`='.mysql_real_escape_string($URL_ID).'');
     $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