Welcome Guest, Not a member yet? Register   Sign In
  Validation fails to fill form elements or error message.
Posted by: El Forum - 08-02-2008, 12:35 PM - Replies (13)

[eluser]valarkin[/eluser]
I am working on a reservation tool and am having problems with the validation. When I validate the information it fails and calls the load view method. However, none of the fields populate, nor does the error message populate.If I echo the error field before loading the view I can see all the errors.

Any ideas what might be causing this?

Here is some code of the code:

(Controller Function that handles Validation)

Code:
function _validateBirthdayReservation() {    
        
        $rules['conFirstName']        = "trim|required";
        $rules['conLastName']        = "required";
        $rules['conAddress']        = "required";
        $rules['conCity']            = "required";
        $rules['conState']            = "required";
        $rules['conZip']            = "required";        
        $rules['conEMail']            = "required";
        $rules['conPhone']            = "required";
        $rules['childFirstName']    = "required";
        $rules['childLastName']        = "required";
        $rules['childDOBDay']        = "required";
        $rules['childDOBMonth']        = "required";
        $rules['childDOBYear']        = "required";
        $rules['childFavColor']        = "required";
        $rules['partyDateDay']        = "required";
        $rules['partyDateMonth']    = "required";
        $rules['partyDateYear']        = "required";
        $rules['partyTime']            = "required";
        $rules['partySodaType']        = "required";
        $rules['partyPizzaType']    = "required";
        $rules['partyNbrKids']        = "required";
        $rules['ccHolderName']        = "required";
        $rules['ccType']            = "required";
        $rules['ccNumber']            = "required";
        $rules['ccExpDateMonth']    = "required";
        $rules['ccExpDateYear']        = "required";

        $this->validation->set_rules($rules);
        
        $fields['conFirstName']        = "Contact First Name";
        $fields['conLastName']        = "Contact Last Name";
        $fields['conAddress']        = "Contact Address";
        $fields['conCity']            = "Contact City";
        $fields['conState']            = "Contact State";
        $fields['conZip']            = "Contact Zip";    
        $fields['conEMail']            = "Contact E-Mail";
        $fields['conPhone']            = "Contact Phone";
        $fields['childFirstName']    = "Child's First Name";
        $fields['childLastName']    = "Child's Last Name";
        $fields['childDOBDay']        = "Child's Date of Birth: Day";
        $fields['childDOBMonth']    = "Child's Date of Birth: Month";
        $fields['childDOBYear']        = "Child's Date of Birth: Year";
        $fields['childFavColor']    = "Child's Favorit Color";
        $fields['partyDateDay']        = "Party Date: Day";
        $fields['partyDateMonth']    = "Party Date: Month";
        $fields['partyDateYear']    = "Party Date: Year";
        $fields['partyTime']        = "Party Time";
        $fields['partySodaType']    = "Party Soda Type";
        $fields['partyPizzaType']    = "Party Pizza Type";
        $fields['partyNbrKids']        = "Number of Kids";
        $fields['ccHolderName']        = "Credit Card Holder Name";
        $fields['ccType']        = "Credit Card Type";
        $fields['ccNumber']            = "Credit Card Number";
        $fields['ccExpDateMonth']    = "Credit Card Expiration: Month";
        $fields['ccExpDateYear']    = "Credit Card Expiration: Year";
        
        $this->validation->set_fields($fields);
        
        if (!$this->validation->run()) {
            //echo $this->validation->error_string;
            $this->load->view('parties_birthday_reservation');
        } else {
            //$this->load->view('formsuccess');
            echo "The form passed all test!";
        }
    }

(A part of the View 'parties_birthday_reservation')

Code:
<label id="conZip-label">Zip:
        &lt;input id="conZip-input" name="conZip" type="text" value="&lt;?=$this-&gt;validation->conZip;?&gt;">
        </label>
        <label id="conEMail-label">E-Mail Address:
        &lt;input id="conEMail-input" name="conEMail" type="text" value="&lt;?=$this-&gt;validation->conEMail;?&gt;">
        </label>
        <label id="conPhone-label">Phone Number:
        &lt;input id="conPhone-input" name="conPhone" type="text" value="&lt;?=$this-&gt;validation->conPhone;?&gt;">
        </label>

(Another part of the View 'parties_birthday_reservation' that handles the error information)
Code:
&lt;?php if ($this->validation->error_string <> ''): ?&gt;
      <div style="float:left; margin-left:10px; width: 310px; padding:10px; border: solid 1px #FF0000; margin-top:10px; color:#FF0000;">
      Error(s): <br />
      &lt;?=$this->validation->error_string;?&gt;
      </div>
      &lt;?php endif; ?&gt;

Any thoughts?


  Image_lib
Posted by: El Forum - 08-02-2008, 12:07 PM - Replies (2)

[eluser]Unknown[/eluser]
Hello every one.
I have some troubles to make my code to work properly.
In my local server (that run PHP 5.2), my application works fine. But when I upload my code on a distant server using PHP 5.2, it doesn't work.
Here is the trouble: I want to resize an uploaded picture using GD library and I receive this error message: Your server does not support the GD function required to process this type of image. The phpinfo() shows me that this library is active in the server.
So what is the matter. Could someone explain to me.
Below is my code:

Code:
//Thumb creator
$config['image_library'] = 'gd';
$config['source_image'] = './ressources/'.$screenshot;
$config['new_image'] = './ressources/thumb/'.$screenshot;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 126;
$config['height'] = 100;
                
$this->load->library('image_lib', $config);                
if(!$this->image_lib->resize())
{
    $erreur.=$this->image_lib->display_errors();
    $err=1;
}
I will use $err to consider the error level.

I am thankfull to every advice.
Thierry


  Creation of a pagination with $_POST data
Posted by: El Forum - 08-02-2008, 11:58 AM - Replies (3)

[eluser]jeanv[/eluser]
Hi everyone, i'm new in the community and this is my first post... Sorry if my english isn't that good, i'm not a native english speaker!

Ok then, so my problem is about the pagination class and the fact that i need to keep the $_POST data to go from a page to another, and the second problem is the url written during the pagination... let me explain you that:

For my pages i have only use a controller and a view file, no model.
My code, in the controller is:

Code:
function index()
{        
if(isset($_POST['search'])) { $this->session->set_userdata('search', $_POST['search']); }
$search = $this->session->userdata('search');

        
    // PAGINATION
    if( $this->uri->segment(3) == '')
    {
        $limit_min = 0;
        $limit_max = 5;
    }
    else
    {
        $limit_min = $this->uri->segment(3);
        $limit_max = 5;
    }
        
    if( isset($search)) )
    {

        // QUERY
        $data['query'] = $this->db->query('
SELECT my-fields
FROM my-tables
WHERE field1 LIKE \'%'.$search.'%\' LIMIT '.$limit_min.','.$limit_max.'');
            

        // NUMBER OF RESULTS

            $nb = $this->db->query('
SELECT my-fields
FROM my-tables
WHERE field1 LIKE \'%'.$search.'%\' ');
            
            $config['base_url'] = base_url().'home/index/';
            $config['total_rows'] = 18; // i don't know how to find this value
            $config['uri_segment'] = 3;
            $config['per_page'] = '5';
            $config['first_link'] = '<<';
            $config['last_link'] = '>>';
            $config['full_tag_open'] = '<p align="center">';
            $config['full_tag_close'] = '</p>';
            $this->pagination->initialize($config);
            
        }

        // Chargement hpage
        if( isset($search))
        {
            $this->load->view('header', $data);
        }
        else
        {
            $this->load->view('header', $data);
        }
        $this->load->view('main', $data);
        $this->load->view('footer');
        
$this->output->enable_profiler(TRUE);
    }

Ok, with this code i have a "correct" pagination, i mean that when i click on the links created by the pagination, the results change and i can go from a page to another.... but it doesn't seem to be good code... i have to use the session library to keep the values and i don't know how the get the number of results for $config['total_rows'].

AND... when for exemple i click on the link "2" (to go to page 2) of the pagination my url is: http://www.mysite.com/home/index/5 and if i click on the link "3" i have http://www.mysite.com/home/index/10


so i would like the point of view of people that know how to do it better because i would like to improve my code... (if possible without model file, i am not very used to MVC achitecture)

Thanks a lot to the guys that will thake time to help me !


  Libraries or HMVC
Posted by: El Forum - 08-02-2008, 11:05 AM - Replies (20)

[eluser]alphasynaptic[/eluser]
So if I'm building an app with CI + Ajax where each page gets content from several different pages and places it onto the main page, should I use libraries despite the fact that I won't be reusing the functions or should I use an HMVC approach? I wish there was a simple way to load controllers from controllers but doesn't look like there is. I believe this isn't a problem of me not understanding the structure or capabilities of MVC but rather the fact that Ajax and MVC do not get along, I could be wrong though. Any help would be appreciated. Thanks in advance.


  Format_text plugin
Posted by: El Forum - 08-02-2008, 09:33 AM - Replies (4)

[eluser]Cro_Crx[/eluser]
Hey all

I was in the middle of creating my first CI app and needed to convert safe tags such as [b] into real html tags <b> and I was also looking for a way to automatically highlight code inside [code] tags. I searched online but couldn't find anything, so I've written my own little plugin. I thought it might be useful for someone.

At the moment the plugin converts bold, underline, italic and code safe-tags. It also automatically creates links by default, although this can be turned off by passing an optional value.

The output text is XHTML compliant and is properly formatted in paragraphs Smile

Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package    CodeIgniter
* @author        ExpressionEngine Dev Team
* @copyright    Copyright (c) 2006, EllisLab, Inc.
* @license        http://ellislab.com/codeigniter/user-guide/license.html
* @link        http://codeigniter.com
* @since        Version 1.0
* @filesource
*/

// ------------------------------------------------------------------------

/*
Instructions:

Load the plugin using:

     $this->load->plugin('format_text');

Once the plugin is loaded you can use it with the following code

&lt;?php format_text($text);  ?&gt;

OR

&lt;?=format_text($text)?&gt;

Autolink is enabled by default.
There is a second optional parameter that can disable autolink for example:

&lt;?php format_text($text, FALSE);  ?&gt;

This will not convert emails/websites to links


*/


function format_text($text, $auto_link = TRUE) {                

    
    // ------------------------------------------------------------------------
    // First We Replace all of our Pseudo-Tags With Real Tags
    
    $text = str_replace("[b]", "<b>", $text);
    $text = str_replace("[/b]", "</b>", $text);
    
    $text = str_replace("[i]", "<i>", $text);
    $text = str_replace("[/i]", "</i>", $text);
    
    $text = str_replace("[u]", "<u>", $text);
    $text = str_replace("[/u]", "</u>", $text);
    
    $text = str_replace("[code]", "<pre>", $text);    // Code is temporarily replaced with <pre>, this gets erased later on anyways. The code used to use <pre> tags, although it uses <code> now and i havn't bothered changing this
    $text = str_replace("[/code]", "</pre>", $text);

    // ------------------------------------------------------------------------
    // Now we run through all the code in our <pre> tags and highlight it, replace the <pre> with <code>
    
    
    $end = FALSE;
    
    do{
        
        if (!$start = strpos($text, '<pre>'))
            $end = TRUE;
            
        if ($end == FALSE)
        {
            $finish =  strpos($text, '</pre>');
            $length = $finish - $start + 6;
            
            $code = substr($text, $start, $length);
            
            $remove = array('<pre>', '</pre>');
            $code = str_replace($remove, "", $code);
            $code = html_entity_decode($code);

            $code = highlight_string($code, TRUE);
            $text = substr_replace($text, $code, $start, $length);
        }
        
    }while($end == FALSE);

    
    // ------------------------------------------------------------------------
    // Add some formatting and line breaks
    
    $text = "<p> ".$text."</p>";                        // Creates start and end paragraphs
    $text = str_replace("\r\n","<br />",$text);        // Replaces Blank lines with <br />
    $text = str_replace("\n","<br />",$text);        // Windows + *nix
    
    // ------------------------------------------------------------------------
    // Now we add paragraphs to all text outside of <code> tags
    
    $start = 0;
    $end = FALSE;
    
    do {

    
        if (!$finish =  strpos($text, '<code>', $start))
            $end = TRUE;
        
        $length = $finish - $start ;
        $paragraph = substr($text, $start, $length);
        $paragraph = str_replace("<br /><br />", "</p><p> ", $paragraph);    // Replaces double line break with new paragraph
        $text = substr_replace($text, $paragraph, $start, $length);
    
        $start = strpos($text, '</code>', $start +1 );
    
    }while($end == FALSE);
    
    
    
    // ------------------------------------------------------------------------
    // Finally we add link tags to websites URL's and email addresses (assuming auto link is true)
    
    if ($auto_link == TRUE)                
        $text = auto_link($text);
    
    return $text;  // YAY :) We managed to output our text :)
    
}



/* End of file format_text_pi.php */
/* Location: ./system/plugins/format_text_pi.php */

BTW: If somone says there's an easier way to do this, or that a plugin has already been written, i'll poke one of my eyes out Smile LOL


  How can I get capitalized controller names?
Posted by: El Forum - 08-02-2008, 09:15 AM - Replies (4)

[eluser]Isos[/eluser]
Hello. I would like to have capitalized controllers that should appear in the URL, something like: www.mywebsite.com/MyBlog .. I tried doing that but I got page not found error.

How can this be done?

Thanks


  directory inside controllers
Posted by: El Forum - 08-02-2008, 08:14 AM - Replies (1)

[eluser]Vans[/eluser]
Hi everyone!!!
Into the directory controllers I have another directory "engine", inside it there are classes that I should call by browser.

What url/uri I must call?

Thank you!


  export web page to pdf on the fly
Posted by: El Forum - 08-02-2008, 08:07 AM - Replies (2)

[eluser]paulcj2[/eluser]
I'd like my site visitors to be able to print the contents of my web pages reformatted on the fly as one page printed flyers. Here's an example on my existing procedurally coded website (soon to be converted to CI).

The web page (workshop information) is here
At the bottom of the page is a link (print flyer) to a page in which this information is converted to a flyer format.

The the page reformatted as a flyer is here

Problem is that visitors will print this page using various platforms, OSs, browsers & printers.

Is there some CI helper or other functionality that can help smooth out the kinks that all these variables cause, so that visitors can get consistently good flyer hard copy?


  wired problem when insert data
Posted by: El Forum - 08-02-2008, 06:26 AM - Replies (3)

[eluser]Unknown[/eluser]
function addThing($thing)
{
foreach( $thing as $key => $value )
{
$this->db->set( $key, addslashes($value) );

}
$this->db->insert('things');


$id = $this->db->insert_id();
if(empty($id))
{
log_message('error', "addThing:" . $this->db->last_query());
}
return $id;

}
Sometimes the insert_id is 0, and no data is inerted into database, but when I execute the logged sql, it can be executed successfully. Does anybody have the save problem or have any ideas about it?
Thanks in advance!


  Need help to get file size while uploading
Posted by: El Forum - 08-02-2008, 06:01 AM - Replies (2)

[eluser]nandish[/eluser]
I try to avoid uploading images according to file size but the thing is am not able to get file size with the help of javascript



function getFilesize(){
var size = document.images['uimgs'].fileSize;
return size;
}
function validate(){
alert(getFilesize()Wink;
}
If i run this script its return undefined in both IE AND FIREFOX


Thanks in Advance


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

Username
  

Password
  





Latest Threads
TypeError when trying to ...
by InsiteFX
33 minutes ago
Webhooks and WebSockets
by InsiteFX
11 hours ago
Retaining search variable...
by pchriley
Today, 05:46 AM
Reading a session variabl...
by xanabobana
Today, 05:05 AM
Update to v4.5.1, same us...
by kenjis
Yesterday, 07:47 PM
Codeigniter 4 extend core...
by Semsion
Yesterday, 05:08 AM
v4.5.1 Bug Fix Released
by lokman
04-16-2024, 02:12 PM
problem with textarea
by Nitin Arora
04-16-2024, 05:07 AM
Showing pdf on browser
by aarefi
04-16-2024, 04:38 AM
[4.5.1] Disabling the deb...
by keto
04-16-2024, 02:43 AM

Forum Statistics
» Members: 84,483
» Latest member: Gritstone Technologies
» Forum threads: 77,558
» Forum posts: 375,892

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB