Welcome Guest, Not a member yet? Register   Sign In
Varible problem
#1

[eluser]pisio[/eluser]
http://picbg.net/img.php?file=4af4a0bfcfcce8a5.png
look this picture.How can I fix a problem ?
The Controler file : useractive.php
Code:
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
* Description of useractive
*
* @author pepi
*/
class useractive extends Controller {
//put your code here
function insert_user()
{
parent::Controller();
header('Content-type: text/html; charset=utf-8');
$dsn = 'mysql://root@localhost/wikis';
$this->load->database($dsn);
$this->load->library('parser');

if($this->uri->segment(3)== 'register'){

if($_POST['user_name'] != NULL AND $_POST['passwd'] == $_POST['passwd'] AND $_POST['email'] != NULL)
{
$this->db->where('username', $_POST['user_name']);
$query = $this->db->get('users');
$useri = $this->db->count_all_results();
if($useri == 0)
{
$data = array( 'id' => '' ,'username' => $_POST['user_name'] ,'password' => md5($_POST['passwd']),'email' => $_POST['email'] , 'activ' => '0' , 'avatar' => 'NULL');
if($this->db->insert('users', $data))
{
$data['user_error'] = 0;
}
}
else
{
$data['user_error'] = 1;
}
}
else
{
$data['user_error'] = 2;
}
}
echo $useri;
$this->parser->parse('user_reg', $data);
// $this->load->view('user_reg');
}
}
?>
View file: user_reg.php
Code:
{data}
{user_error}
{/data}
<form action="http://localhost/wiki/index.php/useractive/insert_user/register" method="POST">
<table border="1">
<tbody>
<tr>
<td>Потребител:</td>
<td>&lt;input type="text" name="user_name" value="" /&gt;&lt;/td>
</tr>
<tr>
<td>Парола<small>(2 пъти)</small>:</td>
<td>&lt;input type="password" name="passwd" value="" /&gt;&lt;br/>&lt;input type="password" name="passwd2" value="" /&gt;&lt;/td>
</tr>
<tr>
<td>Е-поща:</td>
<td>&lt;input type="text" name="email" value="" /&gt;&lt;/td>
</tr>
<tr>
<td>&lt;input type="submit" /&gt;&lt;/td>
</tr>
</tbody>
</table>

&lt;/form&gt;
#2

[eluser]Unknown[/eluser]
having a similar issue
#3

[eluser]djjonex[/eluser]
try changing

$this->db->where('username', $_POST['user_name']);
$query = $this->db->get('users');

by

$query = $this->db->get_where('user', array('username' => $_POST['user_name']));
#4

[eluser]clip[/eluser]
in your controller,

Code:
$_POST['passwd'] == $_POST['passwd']

shouldn't these two be different? Like

Code:
$_POST['passwd'] == $_POST['passwd2']

It would also be good practice to chacke if $data == TRUE before calling $this->parser->parse($data) and maybe do something else if $data is FALSE.
#5

[eluser]pisio[/eluser]
10x , it's fixet.
Now I starting from begin.




Theme © iAndrew 2016 - Forum software by © MyBB