adding www to address(help needed) |
[eluser]plosey[/eluser]
I have function to get the current address(below) if it does not have www. on frot of the domain i want to add it and rerun the query. This query is looking to see if the domain matches a domain in my database (all domains in the database are www.example.com not example.com) so if a user enters example.com i want the query to look for www.example.com not example.com lol hope that makes since. can anyone help me fix my function below to accomplish this? $url = $_SERVER['HTTP_HOST']; $data['result'] = $this->db->where('url', $url); $data['result'] = $this->db->get('sites'); if ($this->db->count_all_results() == 1) { return $data['result']; } else { $url = 'www.'.$_SERVER['HTTP_HOST']; $data['result'] = ''; // same resulte with or without this line $data['result'] = $this->db->where('url', $url); $data['result']=$this->db->get('sites'); return $data['result']; }
[eluser]CroNiX[/eluser]
try Code: ... However, I think it would be best to check the first 3 chars are www before you run the query initially, if it isn't add it and run it. Then you will always only have 1 query run instead of possibly two.
[eluser]plosey[/eluser]
ty for the code and the idea on the bottom. that makes more since on running one query.
[eluser]CroNiX[/eluser]
like Code: $url = $_SERVER[‘HTTP_HOST’];
|
Welcome Guest, Not a member yet? Register Sign In |