• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Form Help

#1
[eluser]garycocs[/eluser]
Hi Lads,

I'm back to have another go at codeigniter, I'm basically starting a new site where the user can add in a youtube link and some data into a database, very very basic stuff. I figured I'd get this site going first with codeigniter and then develop more complex sites.

So I can sort out views and all of that:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;?php $this->load->view('head_view');?&gt;
&lt;body&gt;
&lt;?php $this->load->view('header_div_view');?&gt;


<div id="wrapper">
<div id="mainbody">
<div id="content">


    <div class="window">

    <div class="paneleft">
    <a href="http://karaokeyoutube.net/?p=1" title="Hello world!"><img src="" alt="Hello world!" width="130px" height="97px" /></a></div>

    <div class="paneright">
    <h2 class="indextitle"><a href="http://karaokeyoutube.net/?p=1" rel="bookmark" title="Hello world!">Hello world!</a></h2>

    <div>
    <p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
    <div class="postfeedback">
    <a href="http://karaokeyoutube.net/?p=1#comments" class="commentslink"  title="Comment on Hello world!">Comments (1)</a></div>
    </div>
    </div>
    </div>


    <div class="pagenavigation">
    <div class="alignleft"></div>
    <div class="alignright"></div>
    </div>

</div>

&lt;?php $this->load->view('sidebar_div_view');?&gt;    

</div>

&lt;?php $this->load->view('footer_div_view');?&gt;    

</div>

&lt;/body&gt;
&lt;/html&gt;


Which I call from the main controller.

My question is about form structure, I have the form set up like so:
Code:
<h2>Add Video</h2>

&lt;?php
    echo form_open('email/send');
    echo "<p>Artist<br />";
    echo form_input('artist', '');
    echo "</p><p>Title<br />";
    echo form_input('name', '');
    echo "</p><p>YouTube Link<br />";
    echo form_input('link', '');
    echo "</p><p>Song Type<br />";    

    $typearray = array();
    $this->db->select('id');
    $this->db->select('name');
    $this->db->from('type');
    $query = $this->db->get();

    if ($query->num_rows()>0)
    {
        foreach($query->result() as $row)
        {
            $typearray[$row->id] = $row->name;
        }
    }
    echo form_dropdown('type', $typearray);
    echo "</p><p>Song Year<br />";    

    $agearray = array();
    $this->db->select('id');
    $this->db->select('name');
    $this->db->from('age');
    $query = $this->db->get();

    if ($query->num_rows()>0)
    {
        foreach($query->result() as $row)
        {
            $agearray[$row->id] = $row->name;
        }
    }
    echo form_dropdown('type', $agearray);



    echo "</p><p>";
    echo form_submit('mysubmit', 'Add Video!');
    echo "</p>";    
    echo form_close();
?&gt;

Which to me is not really using the MVC as there are DB requests etc in the view.

Could someone please explain to me the proper conventions for form structure, where do I set it up? Where do I post the inputs to? Where does the validation go?

Any help would be much appreciated. I probably could hack it out I just want to do things right since I'm starting!

Thanks
Gary


Messages In This Thread
Basic Form Help - by El Forum - 08-03-2009, 08:27 AM
Basic Form Help - by El Forum - 08-03-2009, 08:57 AM
Basic Form Help - by El Forum - 08-03-2009, 08:59 AM
Basic Form Help - by El Forum - 08-03-2009, 09:01 AM
Basic Form Help - by El Forum - 08-03-2009, 11:43 AM
Basic Form Help - by El Forum - 08-03-2009, 01:36 PM
Basic Form Help - by El Forum - 08-04-2009, 04:39 PM
Basic Form Help - by El Forum - 08-04-2009, 07:41 PM
Basic Form Help - by El Forum - 08-05-2009, 07:14 AM
Basic Form Help - by El Forum - 08-05-2009, 09:37 AM
Basic Form Help - by El Forum - 08-05-2009, 10:18 AM
Basic Form Help - by El Forum - 08-05-2009, 11:11 AM
Basic Form Help - by El Forum - 08-05-2009, 12:23 PM
Basic Form Help - by El Forum - 08-05-2009, 12:41 PM
Basic Form Help - by El Forum - 08-05-2009, 01:01 PM
Basic Form Help - by El Forum - 08-05-2009, 01:09 PM
Basic Form Help - by El Forum - 08-11-2009, 07:51 AM
Basic Form Help - by El Forum - 08-11-2009, 08:39 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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