Welcome Guest, Not a member yet? Register   Sign In
weird characters in the url
#21

[eluser]osci[/eluser]
I wasn't aware of the problem as I realized. I was not using posts

Here is an example with posts
It's not combined with previous code cause I wanted to check seperately the post but you can combine it easily.

Controller
Code:
function post_result()
{
   $this->load->view('/post_test');
}

function test_result($q='-')
{
   $q = $this->input->post('q',true);
   $render['data'] = $this->news_model->get_test($q);
   $this->load->view('/post_result',$render);
}

Model
Code:
function get_test($slug) {
    $query = $this->db->from('t_news')->like('title', $slug)->get();
    return $query->result();
}

Post view
Code:
<!DOCTYPE html>
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv='content-type' content='text/html; charset=utf-8' /&gt;
&lt;/head&gt;
&lt;body&gt;
   &lt;?php echo form_open('news/test_result');?&gt;
   &lt;input type="text" name="q" id="q" /&gt;
   &lt;input type="submit" value="submit" /&gt;
   &lt;?php echo form_close(); ?&gt;
&lt;/body&gt;
&lt;/html&gt;

Result view
Code:
<!DOCTYPE html>
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv='content-type' content='text/html; charset=utf-8' /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php foreach($data as $row) : ?&gt;
&lt;?php echo $row->title; ?&gt;<br />
&lt;?php endforeach; ?&gt;
&lt;/body&gt;
&lt;/html&gt;
#22

[eluser]dianikol85[/eluser]
As far as i can understand you pass the
Code:
$q = '-'
in
Code:
function test_result($q='-')
{
   $q = $this->input->post('q',true);
   $render['data'] = $this->news_model->get_test($q);
   $this->load->view('/post_result',$render);
}

so we can have the pagination according to the search criteria.

So lets say in the second page i will still have the $q in the url. right? I have done this too the redirect instead of loading the view. But the prob is when i have greeks. because in the second page i get search criteria from the url not from the $_POST array and that's whene i got the hex value. Because it's from the url.


@osci do you mind to attach a sample to take a look at it?? tha exw sxolia sta ellinika
#23

[eluser]osci[/eluser]
you can attach, I'll look at it till tomorrow. Need a break and some food too for now Smile
#24

[eluser]dianikol85[/eluser]
i finally get it right. I manage to return a success sql query. By the way the hex to string operation must be done for greek words otherwise it return hex because it is $_GET request. If it was $_POST no problem at all
#25

[eluser]osci[/eluser]
glad to see you got it fixed. I used post with my code, you said about submiting from form and I just thought of post. I'll try to check later my code with get and post the results here.
#26

[eluser]dianikol85[/eluser]
[quote author="osci" date="1302533772"]glad to see you got it fixed. I used post with my code, you said about submiting from form and I just thought of post. I'll try to check later my code with get and post the results here.[/quote]

Thanks. Just try to have greek in the url while you have pagination

Code:
test.loc/controller/index/τεστ

and echo out the third segment lets say in the second page to see if you get hex value as i do.

I'm waiting for your results




Theme © iAndrew 2016 - Forum software by © MyBB