Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,963
» Latest member: Rebert
» Forum threads: 66,227
» Forum posts: 415,572

Full Statistics

Latest Threads
The best auth library
Forum: Addins
3 minutes ago
» Replies: 5   » Views: 1,605
Why the hate for CI still
Forum: Choosing CodeIgniter
2 hours ago
» Replies: 17   » Views: 2,639
Codeigniter 3 File Upload...
Forum: General Help
9 hours ago
» Replies: 6   » Views: 208
A Simple Forum Software b...
Forum: CodeIgniter 4 Discussion
10 hours ago
» Replies: 4   » Views: 193
Ajax if no result return ...
Forum: General Help
10 hours ago
» Replies: 2   » Views: 71
Codeignitor 3.1.5 cant fi...
Forum: General Help
Today, 08:32 AM
» Replies: 4   » Views: 75
How do I make a database ...
Forum: General Help
Today, 04:24 AM
» Replies: 12   » Views: 327
form validation: discrete...
Forum: General Help
Today, 04:21 AM
» Replies: 0   » Views: 36
CSRF multiple tab issue o...
Forum: Issues
Today, 03:58 AM
» Replies: 1   » Views: 75
CodeIgniter 3.1.5 Release...
Forum: News & Discussion
Today, 03:55 AM
» Replies: 25   » Views: 6,274

 
  CodeIgniter Form Validation for a Name
Posted by: june123 - Yesterday, 03:56 AM - Forum: General Help - Replies (4)

Hello,

When a form takes a person's name as input, it is usually two or three strings separated by spaces i,e. Henry David Lee.

However going through CodeIgniter validation rules I couldn't find any rule which supports this.

I could find alpha and alpha_dash which wont validate a name.

Maybe something like alpha_space is needed so that we dont need to create callback functions for it.

Please correct me if I have missed something.


  can't upload this image with utf8 characters and problem with json_encode
Posted by: GoldenFingers - Yesterday, 02:03 AM - Forum: General Help - Replies (2)

hi , guys 

i can't upload this image in the attachment
because it's contain utf8 characters

this is result

 

PHP Code:
 [raw_name] => ٢�_١٥١١�_٥_١٤٤٧٣٣_(2)7
    
[orig_name] => ٢�_١٥١١�_٥_١٤٤٧٣٣_(2).jpg
    
[client_name] => ٢٠١٥١١٠٥_١٤٤٧٣٣ (2).jpg 
 
and this file name after upload 
ظ¢ظ_ظ،ظ¥ظ،ظ،ظ_ظ¥_ظ،ظ¤ظ¤ظ§ظ£ظ£_(2).jpg

and i can't use this result in json with JSON_UNESCAPED_UNICODE flag


Any suggestion  Sad Sad



Attached Files
.zip   img.zip (Size: 265.13 KB / Downloads: 9)

  Codeigniter 3 File Upload Issue
Posted by: codeigniterd - 06-26-2017, 02:11 PM - Forum: General Help - Replies (6)

View File

Code:
<form id="DocUploadForm" action="" method="post" enctype="multipart/form-data">
                                        <div class="box-body">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label for="pdocupload">Upload Document</label>
                                                    <input type="file" id="pdocupload" name="pdocupload">
                                                    <p class="help-block">Example .pdf,.jpg,.doc, .docx files</p>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                            </div>
                                            <div class="clearfix"></div>
                                            <div class="box-footer">
                                                <input id="UserId" name="UserId" type="hidden" value="">
                                                <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" >
                                                <button id="pdu_cancel" name="pdu_cancel" type="button" onclick="pduCancelFunc();" class="btn btn-default">Cancel</button>
                                                <button id="pdu_submit" name="pdu_submit" type="button" onclick="pduUploadFunc();" class="btn btn-info">Upload</button>
                                            </div>
                                        </div>
                                    </form>

JS File *i am using jquery validate to validate the form
Code:
$("#DocUploadForm").validate({
                rules: {
                    pdocupload: {
                        required: true
                    }
                },
                messages: {
                    pdocupload: {
                        required: "Choose some files first"
                    }
                },
                submitHandler: function(form) {
                    //$.LoadingOverlay('show');
                    var dataString = $(form).serialize();
                    $.ajax({
                        url: "<?php echo site_url('mycontroller/DocUploadFormSubmit'); ?>",
                        type: "POST",
                        cache: false,
                        data: dataString,
                        success: function(response) {
                            alert(response);
                        }            
                    });
                    return false;
                }
            });
       });
        
function pduUploadFunc()
{
    $("#DocUploadForm").submit();
}
Controller
Code:
$config['upload_path']          = './assets/';
$config['allowed_types']        = 'gif|jpg|png|pdf|doc|docs';
$config['max_size']             = 8048;
//$config['max_width']            = 0;
//$config['max_height']           = 0;

$this->load->library('upload', $config);

$claenUserId = $this->security->xss_clean($this->input->post('UserId'));

if($this->upload->do_upload('pdocupload'))
{
   echo "file upload success";
}
else
{
   echo "file upload failed";
}

I is always showing "file uoload failed". There is no permission issues. i have checked. Dont know the reason !! Thanks in advance for help. Smile


  How to edit record codeigniter CRUD?
Posted by: ozzy - 06-26-2017, 01:09 PM - Forum: General Help - Replies (2)

I would like to add simple edit functionality which unfortunately was not covered in tut,I would like to have an edit button that opens a form and update info.
I followed tut from here:https://code.tutsplus.com/articles/codei...--net-6504

Here is my Contrroller:

Code:
<?php

class Site extends CI_Controller
{

    function index()
    {

        $data = array();
        
        if($query = $this->site_model->get_records())
        {
            $data['records'] = $query;
        }
        //$this->load->library('table');
        $this->load->view('options_view',$data);
    }

    function create()
    {
        $data = array(
            'title' => $this->input->post('title'),
            'content' => $this->input->post('content')
            );

        $this->site_model->add_record($data);        
        $this->index();
    }

    function update()
    {
         $data = array (
             'title' => 'My NEW UPDATED title',
             'content' => 'NEW UPDATED content; UPDATED'
            );
         $this->site_model->update_record($data);    
   }

    


     function delete()
     {
         $this->site_model->delete_row();
         $this->index();
     }

}

?>
Here is my Model:

Code:
<?php

class Site_model extends CI_Model {

    function get_records()
    {
         $query = $this->db->get('assets');
         return $query->result();
        // $query = $this->db->query('SELECT * FROM assets');
        //echo $this->table->generate($query);

    }


    function add_record($data)
    {
        $this->db->insert('assets', $data);
        return;
    }

    function update_record($data)
    {
        $this->db->where('id', 3);
        $this->db->update('assets', $data);
    }

    

     function delete_row()
      {
          $this->db->where('id', $this->uri->segment(3));
          $this->db->delete('assets');

       }


}
Here is my View:

Code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled</title>
    <style type="text/css" media="screen">
        label{display:block;}
    </style>
</head>
<body>

<h2>Create</h2>
<?php echo form_open('site/create');?>

<p>
    
<label for="title">Title:</label>
<input type="text" name="title" id="title" />

</p>

<p>
    
<label for="content">Content:</label>
<input type="text" name="content" id="content" />

</p>

<p>
    
    <input type="submit" value="submit" />    

</p>


<?php echo form_close(); ?>

<hr />


<!-- <h2>Read</h2> -->
<h2>Read</h2>
<table>
<?php if(isset($records)) : foreach ($records as $row) : ?>  
<tr>
<td>
<?php echo anchor("site/delete/$row->Id", $row->title); ?>
<td>
<td><?php echo $row->content; ?> </td>
<tr>
    <td></td><td></td><td></td><td></td><td>edit</td>
</tr>

</tr>

<?php endforeach; ?>
</table>

<?php else : ?>

<h2>No records returned.</h2>

<?php endif; ?>




<hr />

<h2>Delete</h2>

<p>To sample the delete method, click on on of the headings above.
A delete query will automatically run.
</p>

</body>
</html>


  [split] Upload library issue with 3.1.5?
Posted by: Carlos Villegas - 06-26-2017, 11:53 AM - Forum: CodeIgniter 3.x - No Replies

Can you please double check  Library Upload please ?
There is sometimes when the  file  doesn't  exist in the server.



This function  worked well on  3.0.6:

  public function upload_documents($id)
    {

        $config['upload_path']   = './uploads/pedidos/files/';
        $config['allowed_types'] = '*';
        $config['overwrite']     = false;
        $files = $_FILES;
        
        $this->load->library('upload', $config);

        $row['id_pedido'] = $id;
        $row['fecha']     = date('Y-m-d H:i:s');
        $row['estatus']   = 1;

        if (isset($files['documentos'])) {
            for ($i = 0; $i < count($files['documentos']['name']); $i++) {
                if ($files['documentos']['size'][$i] > 0) {
                    $_FILES['documento']['name']  = Str::cleanFilename($files['documentos']['name'][$i]);
                    $_FILES['documento']['type']  = $files['documentos']['type'][$i];
                    $_FILES['documento']['size']  = $files['documentos']['size'][$i];
                    $_FILES['documento']['error'] = $files['documentos']['error'][$i];
                    $_FILES['documento']['tmp_name'] = $files['documentos']['tmp_name'][$i];
                    if ($this->upload->do_upload('documento')) {
                        
                        $row['nombre'] = Str::minifySpaces($files['documentos']['name'][$i]);

                        $row['ruta'] = 'uploads/pedidos/files/' . $this->upload->data('file_name');
                        
                        $this->db->insert('documento_pedido', $row);
                    } else {
                        $this->session->set_flashdata('error_header', '<p>Falló la subida de un archivo, por favor intenta de nuevo.</p>');
                        $this->session->set_flashdata('errors', $this->upload->display_errors());
                    }
                }
            }
        }
    }


  How do I make a database row be a global?
Posted by: desbest - 06-26-2017, 05:20 AM - Forum: General Help - Replies (12)

How do I make a database row be a global?
I've used google search for answers and none of the results helped me.

I am using this tutorial.

Here is config/globals.php


Code:
<?php

// Create customized config variables
$config['web_Address']= 'https://www.formget.com/blog';
$config['title']= 'CodeIgniter Global Variable';

$this ->load->database();  
$config['me']= $this->db->query("SELECT * from users WHERE id='$_COOKIE[userid]' && password ='$_COOKIE[pass]'"); $me = $me->row_array();

?>

Here are the errors I get.
Undefined property: CI_Loader::$load on Line 7
Call to a member function database() on null on Line 7

Is there a good way of making a database row a global? I am writing my own authentication system as Codeigniter doesn't come with one.


  Failover results are wrong
Posted by: bunnyps - 06-26-2017, 04:18 AM - Forum: Issues - Replies (1)

Hi,

at first, sorry for my bad english - i am german ;-)

I have the following Setup:

- Debian 8.0
- MSSQL DB Servers (1xStandard and 1x for Failover, if the first one is down)
- Apache2 and the actually CI Version

CI works great wie both DB Servers, when i changed it manual.

But, when i use one (doesnt matter wich one) as failover and turn down the normal DB Server, i have strange results.

1) I have Problemes with unicode signs. For Example Ö => �
2) I use to have 5 or more Queries when the System starts. All normal Queries are working well with �, but the results are complete. Some, not all, Queries via AJAX (the Same Queries but via AJAX Request) have NULL or 10 or 15 or all from 100 Resultobjects.

I use PHP 7.x

When i do the same on localhost with xampp i have no errors with the failover configuration. My DB Driver is FreeTDS on the Debian System.

Have someone any ideas what i can try - oder have to configured to solve this?

Greetings and many Thanx in Advance


  Undefined property: Admin::$db when I put database on autoload
Posted by: desbest - 06-26-2017, 03:37 AM - Forum: General Help - Replies (3)

I'm getting this error when trying to interact with the database with ORM.
Undefined property: Admin::$db

Stack Overflow says I should put database inside the libraries section of autoload.php

I have already done this and I still get the error. It reads 

$autoload['libraries'] = array('database');

Please help.


  How to set and read a flash variable?
Posted by: desbest - 06-25-2017, 11:13 AM - Forum: General Help - Replies (1)

I've been reading the documentation.
https://codeigniter.com/user_guide/libra...k_as_flash

Do I use mark_as_flash($variable); to use it?

Also flashdata() which is supposed to be used to get flash variables, is a legacy method. What do I use instead?

The documentation says to store stuff in the session, but what if I want the framework to give me temporary variables that only exist in the next page load? Does Codeigniter have flash variable functionality?


  codeigniter captcha Allowed memory
Posted by: pippuccio76 - 06-25-2017, 08:16 AM - Forum: General Help - Replies (2)

Hi , im tryng to insert captcha in registration , this is my simple controller method :

Code:
public function captcha_setting(){
       
        $this->load->helper('captcha');

       
       $vals = array(
           'img_path' => '.images/',
           'img_url' => base_url().'images/',
       );
       
       
        $data = create_captcha($vals);
       
        $_SESSION['captchaWord'] = $data['word'];
       
        $this->captcha_setting();


        // image will store in "$data['image']" index and its send on view page
        $this->load->view('captcha_view', $data);
     }


If i visit the page captcha_view :

Code:
<?php

echo $image;


?>


I have this error  :

Message: Allowed memory size of 268435456 bytes exhausted (tried to allocate 65484 bytes)



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.