Jump to content

booxvid

Members
  • Posts

    32
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

booxvid's Achievements

Member

Member (2/5)

0

Reputation

  1. I was trying to make form wherein you give you a title and its description plus, you can upload photo with it. The problem is.. I had the difficulty in saving together the texts and also the photo my text and photo details are saved into one database table which is named, "texts" here's my controller: function addpost(){ /*ID IS THE BLOG PAGE ID*/ $id = $this->uri->segment(3); $username = $this->session->userdata('username'); $userid = $this->blog_model->get_id('username',$username); $this->form_validation->set_rules('blogtitle','Blog Title','is_unique[texts.text_title]'); $this->form_validation->set_rules('desc','Description','required'); $this->form_validation->set_error_delimiters(' ',''); if($this->form_validation->run()==FALSE){ echo ""; $this->view_posts(); } else{ $title =$this->input->post('blogtitle'); $desc = $this->input->post('desc'); $timezone = "Asia/Manila"; date_default_timezone_set ($timezone); $date = date("Y-m-d"); $timetoday = date("H:i:s"); $photo = $this->input->post('upload'); if ($photo) { /*UPLOAD IT AND SAVE IT TO THE PROFILE FOLDER AND ITS THUMBNAIL AS WELL*/ $data_second=$this->blog_model->do_uploadthispost($userid); print_r($data_second); } $data = array( 'text_title'=>$title, 'text_content'=>$desc, 'text_date'=>$date, 'text_time'=>$timetoday, 'text_user_id'=>$userid, 'text_blogpage_id'=>$id ); $userdata = array( 'username' => $username, 'logged_in' => TRUE, 'user_id' => $userid ); $new_data = $data + $data_second; $this->blog_model->create_new($newdata,'texts'); /*GIVES A PROMPT MESSAGE THAT YOU SUCCESSFULLY CREATED A BLOG*/ echo ""; $this->view_posts(); } } and here's the model: in my model i have these variable inside my construct : $this->photos_path = realpath(APPPATH. '../assets/img/posts/'); $this->photos_path_url = base_url().'assets/img/posts/'; wherein i have this variables before my construct: var $photos_path; var $photos_path_url; and this is my main function from my blog_model which it will upload the photo hopefully in the requested dir and its thumbnail also: function do_uploadthispost() { $config = array( 'allowed_types' => 'jpg|jpeg|gif|png', 'upload_path' => $this->photos_path, 'max_size' => 10000 ); $this->load->library('upload', $config); $this->upload->do_upload(); $image_data = $this->upload->data(); $config = array( 'source_image' => $image_data['full_path'], 'new_image' => $this->photos_path . '/thumbs', 'maintain_ratio' => true, 'width' => 690, 'height' => 900 ); $this->load->library('image_lib', $config); $this->image_lib->resize(); $filepath = $image_data['file_path']; $filename = $image_data['file_name']; $type = $image_data['file_type']; $size = $image_data['file_size']; $data = array(); /*SAVE IT INTO THE DATABASE*/ if($size<10000){ $data = array( 'filename'=>$filename, 'filepath'=>$filepath, 'type'=>$type, 'size'=>$size, ); //$this->update_this($data,); } return $data; } also: here's the portion where i placed my form: <div id="myModal" class="modal hide fade"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <?php echo heading('Add Post',3); ?> </div> <div class="modal-body"> <hr> <?php $attributes = array('class'=>'form-inline','id'=>'thisForm'); echo form_open_multipart('posts/addpost/'.$idblog.'',$attributes); echo form_label('Title:','title'); $data_input_fname = array( 'class'=>'input-large', 'name'=>'blogtitle', 'id'=>'blogtitle', 'maxlength'=>'100', 'placeholder'=>'Insert you blog title here'); echo nbs(3); echo br(1); echo form_input($data_input_fname); echo br(2); echo form_upload('userfile',array('class'=>'btn btn-primary')); echo br(2); echo form_label('Content:','content'); $data_inputdesc = array( 'type'=>'textarea', 'style'=>'width: 500px; height: 150px', 'class'=>'input-large', 'name'=>'desc', 'id'=>'desc', 'placeholder'=>'Insert text here' ); echo nbs(2); echo form_textarea($data_inputdesc); ?> <br/><br/> <center> <?php $submit_data = array('type'=>'submit', 'class'=>'btn btn-large btn-primary', 'name'=>'submit_form', 'value'=>'Submit!'); echo form_submit($submit_data); echo nbs(5); $reset_data = array('type'=>'reset', 'class'=>'btn btn-large', 'name'=>'reset_form', 'value'=>'Reset!'); echo form_reset($reset_data); echo form_close(); ?></center> </div><!---modal body --> </div>
  2. Is there another way that I could separate the date and time because I have two columns in my mysql table the blog_date and blog_time
  3. public function create_blog(){ $this->load->view('header'); $this->form_validation->set_rules('blogtitle','Blog Title','required'); $this->form_validation->set_rules('desc','Description','required'); $this->form_validation->set_error_delimiters(' ',''); if($this->form_validation->run()==FALSE){ $this->load->view('view_dashboard_addblog'); } else{ $title =$this->input->post('blogtitle'); $desc = $this->input->post('desc'); $data = array( 'blog_title'=>$title, 'description'=>$desc, 'blog_date'=>CURDATE(), 'blog_time'=>CURTIME()); $this->blog_model->insert_posts($data); echo ""; $this->load->view('view_blog'); } } My problem is, curdate() and curtime() function for mysql doesn't work at all, it says an undefined function, how to get the current date and time in Codeigniter and insert it into my mysql table
  4. Here's the snippet code in controller: public function me_login(){ $this->load->view('header'); $this->form_validation->set_rules('username','First Name','required'); $this->form_validation->set_rules('password','Last Name','required'); $this->form_validation->set_error_delimiters(' ',''); if($this->form_validation->run()==FALSE){ $this->load->view('view_login'); } else{ $u= $this->input->post('username'); $p= $this->input->post('password'); $username = trim($u); $password = trim($p); //search same info from db $boolean = $this->blog_model->login($username,$password); if($boolean){ $userdata = array( 'username' => $username, 'logged_in' => TRUE ); $this->session->set_userdata($userdata); echo ""; $this->load->view('view_home',$userdata); } else{ echo ""; $this->load->view('view_login'); } } } here's my blog_model where my login function located: public function login($username,$password){ $encode = $this->encrypt->encode($password); $query = $this->db->get_where('blog_user', array('username' => $username, 'securepass' => $encode)); return $query->result(); } I don't know why my Login function will always be failed.
  5. How to set value in an input field? I'm using a codeigniter framework; <?php $data_input_fname = array('class'=>'input-large', 'name'=>'firstname', 'id'=>'firstname', 'value'=>set_value('<?php echo $fname;?>'), 'maxlength'=>'100'); echo form_input($data_input_fname); <?php $data_input_fname = array('class'=>'input-large', 'name'=>'firstname', 'id'=>'firstname', 'value'=>set_value($fname), 'maxlength'=>'100'); echo form_input($data_input_fname); i already tried those two, but nothing come out in my input field.
  6. I don't where this error come from \: The error was: my function update in my model [code=php:0] public function update_posts($data,$id){ $this->db->where('idblog_user', $id) ->update('blog_user',$data); return; } [/code] my two functions in my controller [code=php:0]public function updateform(){ $data = array(); $data['posts']=$this->blog_model->getthis_records(); $this->load->view('view_update',$data); } public function updatethis(){ $this->form_validation->set_rules('firstname','First Name','required|alpha_numeric'); $this->form_validation->set_rules('lastname','Last Name','required|alpha_numeric'); $this->form_validation->set_rules('gender','Gender','required'); $this->form_validation->set_rules('month','Month','required'); $this->form_validation->set_rules('month','Day','required'); $this->form_validation->set_rules('year','Year','required'); $this->form_validation->set_rules('email','Email Address','required|valid_email|is_unique[idblog_user.email]'); $this->form_validation->set_rules('username','Username','required|min_length[5]|max_length[12]|is_unique[idblog_user.username]|alpha_dash'); $this->form_validation->set_rules('password','Password','required|min_length[6]|max_length[12]'); $this->form_validation->set_error_delimiters('<br /><span class="error"> ','</span>'); if($this->form_validation->run()){ $fname =$this->input->post('firstname'); $lname = $this->input->post('lastname'); $gender = $this->input->post('gender'); $month = $this->input->post('month'); $day = $this->input->post('day'); $year = $this->input->post('year'); $date = sprintf('%s-%s-%s',$year,$month,$day); $eadd = $this->input->post('email'); $username = $this->input->post('username'); $password = $this->input->post('password'); $data = array('firstname'=>$fname,'lastname'=>$lname,'gender'=>$gender, 'birthday'=>$date,'email'=>$eadd,'username'=>$username,'password'=>$password); $id=$this->uri->segment(3); $printquery = $this->blog_model->update_posts($data,$id); echo $printquery; if($this->blog_model->update_posts($data,$id)){ redirect(); } else{ // $this->messages->error('There was an error updating this product\'s attributes...'); echo "UN"; } } } [/code] and in my view: [code=php:0] <div> <?php echo heading('Current Data:',3);?> <?php foreach ($posts as $p):?> <?php echo form_label('First Name:','firstname')." ". $p['firstname']; echo br(2);?> <?php echo form_label('Last Name:','lastname')." ". $p['lastname']; echo br(2);?> <?php echo form_label('Birthday:','birthday')." ". $p['birthday']; echo br(2);?> <?php echo form_label('Email Address:','email')." ". $p['email']; echo br(2);?> <?php echo form_label('Username:','username')." ". $p['username']; echo br(2);?> <?php endforeach; echo nbs(4);?> </div> <div> <div class="form"> <?php foreach ($posts as $p):?> <?php $attributes = array('class'=>'well form-inline','id'=>'thisForm'); echo form_open('blog/updatethis/'.$p['idblog_user'].'',$attributes)?> <?php endforeach;?> <table cellspacing="2" cellpadding="10" border=0> <tr> <td><?php echo heading('REGISTRATION FORM',3);?></td> </tr> <tr> <td><?php echo form_label('First Name:','firstname')?></td> <td><?php $data_input_fname = array('class'=>'input-large', 'name'=>'firstname', 'id'=>'firstname', 'maxlength'=>'100'); echo form_input($data_input_fname); ?> </td> </tr> <tr> <td><?php echo form_label('Last Name:','lastname')?></td> <td><?php $data_input_lname = array('class'=>'input-large', 'name'=>'lastname', 'id'=>'lastname', 'maxlength'=>'100'); echo form_input($data_input_lname); ?></td> </tr> <tr> <td><?php echo form_label('Gender:','gender')?></td> <td><?php $gender_f = array('name'=>'gender', 'type'=>'radio'); $gender_m = array('name'=>'gender', 'type'=>'radio' ,'value'=>'Male'); echo form_radio($gender_f).' Female'; echo nbs(3); echo form_radio($gender_m).' Male'; ?></td> </tr> <tr> <td><?php echo form_label('Birthday:','birthday')?></td> <td><?php $options = array(''=>'Month', '01'=>'January', '02'=>'February', '03'=>'March', '04'=>'April', '05'=>'May', '06'=>'June', '07'=>'July', '08'=>'August', '09'=>'Septembr', '10'=>'October', '11'=>'November', '12'=>'December'); echo form_dropdown('month',$options,''); $options2 = array(''=>'Day', '01'=>'1', '02'=>'2', '03'=>'3', '04'=>'4', '05'=>'5', '06'=>'6', '07'=>'7', '08'=>'8', '09'=>'9', '10'=>'10', '11'=>'11', '12'=>'12', '13'=>'13', '14'=>'14', '15'=>'15', '16'=>'16', '17'=>'17', '18'=>'18', '19'=>'12', '20'=>'20', '21'=>'21', '22'=>'22', '23'=>'23', '24'=>'24', '25'=>'25', '26'=>'26', '27'=>'27', '28'=>'28', '29'=>'29', '30'=>'30', '31'=>'31'); echo form_dropdown('day',$options2,''); $year = array(); for($i=1800;$i<=2012;$i++){ $year[$i]= $i; } $year_my = array_combine($year,$year); echo form_dropdown('year', $year_my); ?></td> </tr> <tr> <td><?php echo form_label('Email:','email address')?></td> <td><?php $data_inpute = array('class'=>'input-large', 'name'=>'email', 'id'=>'email', 'maxlength'=>'100'); echo form_input($data_inpute); ?></td> </tr> <tr> <td><?php echo form_label('Username:','username')?></td> <td><?php $data_input = array('class'=>'input-large', 'name'=>'username', 'id'=>'username', 'maxlength'=>'100'); echo form_input($data_input); ?></td> </tr> <tr> <td><?php echo form_label('Password:','password')?></td> <td><?php $data_pass = array('class'=>'input-large', 'name'=>'password', 'id'=>'password', 'maxlength'=>'100', 'type'=>'password'); echo form_password($data_pass); ?></td> </tr> <tr> <td colspan=2> <?php if(validation_errors()): echo validation_errors(); endif;?> </td> </tr> <tr> <td colspan="2"><center> <?php $submit_data = array('type'=>'submit', 'class'=>'white button', 'name'=>'submit_form', 'value'=>'Submit!'); echo form_submit($submit_data); $reset_data = array('type'=>'reset', 'class'=>'white button', 'name'=>'reset_form', 'value'=>'Reset!'); echo form_reset($reset_data);?></center> </td> </tr> <?php form_close();?> </table> </div> </div> [/code]
  7. I have an index function of my controller which it's the index page of my application, and in my reg_form function in my controller I load my view_registration.php the php file has a css design that's attached by the header.php already that's in my index function when I view the page of my registration form, there's no design? Is there a way that I can load my css file in a function from a controller?
  8. Using frameworks will avoid you in having a spaghetti code and having libraries of functions already that we always use in every web application.
  9. Requiring fields validation is already done but my other validations wouldn't work. Here's my controller: my validation process is placed with a validation function: public function reg_validation(){ $this->form_validation->set_rules('firstname','First Name','required|min_length[5]'); $this->form_validation->set_rules('lastname','Last Name','required'); $this->form_validation->set_rules('gender','Gender','required'); $this->form_validation->set_rules('course','Course','required'); $this->form_validation->set_rules('interest','Interest','required'); $this->form_validation->set_rules('desc','Description','required'); $this->form_validation->set_rules('username','Username','required|min_length[5]|max_length[12]|is_unique[user.username]'); $this->form_validation->set_rules('password','Password','required|min_length[6]|max_length[12]'); $this->form_validation->set_error_delimiters('<br /><span class="error"> ','</span>'); if($this->form_validation->run()==FALSE){ $this->load->view('view_registration'); } else{ $this->create(); redirect(); } } then here's my view_registration.php [code=php:0] <div> <div class="form"> <?php $attributes = array('class'=>'well form-inline','id'=>'thisForm'); echo form_open('',$attributes)?> <table cellspacing="2" cellpadding="10" border=0> <tr> <td><?php echo heading('REGISTRATION FORM',3);?></td> </tr> <tr> <td><?php echo form_label('First Name:','firstname')?></td> <td><?php $data_input_fname = array('class'=>'input-medium', 'name'=>'firstname', 'id'=>'firstname', 'maxlength'=>'100', 'value'=>set_value()); echo form_input($data_input_fname); echo br(1); if(!$this->input->post('firstname')){ echo form_error('firstname');}?> </td> </tr> <tr> <td><?php echo form_label('Last Name:','lastname')?></td> <td><?php $data_input_lname = array('class'=>'input-medium', 'name'=>'lastname', 'id'=>'lastname', 'maxlength'=>'100'); echo form_input('lastname'); echo br(1); if(!$this->input->post('lastname')){ echo form_error('lastname');}?></td> </tr> <tr> <td><?php echo form_label('Gender:','gender')?></td> <td><?php $gender_f = array('name'=>'gender', 'type'=>'radio' ,'value'=>'Female'); $gender_m = array('name'=>'gender', 'type'=>'radio' ,'value'=>'Male'); echo form_radio($gender_f).' Female'; echo nbs(3); echo form_radio($gender_m).' Male'; echo br(1); if(!$this->input->post('gender')){ echo form_error('gender');}?></td> </tr> <tr> <td><?php echo form_label('Course:','course')?></td> <td><?php $options = array(''=>'No Course', 'Bachelor of Science in Information Technology'=>'BSIT', 'Bachelor of Science in Computer Science'=>'BSCS', 'Bachelor of Science in Accountancy'=>'BSA', 'Bachelor of Science in Nursing'=>'BSN'); echo form_dropdown('course',$options,''); echo br(1); if(!$this->input->post('course')){ echo form_error('course');}?></td> </tr> <tr> <td><?php echo form_label('Interests:','interest')?></td> <td><?php echo form_checkbox('interest','Music','').' Music'; echo br(1); echo form_checkbox('interest','Art','').' Art'; echo br(1); echo form_checkbox('interest','Speech','').' Speech'; echo br(1); echo form_checkbox('interest','Logic','').' Logic'; echo br(1); if(!$this->input->post('interest')){ echo form_error('interest');}?></td> </tr> <tr> <td><?php echo form_label('Description:','desc')?></td> <td><?php $data_textarea = array('type'=>'textarea', 'name'=>'desc', 'row'=>5, 'cols'=>25); echo form_textarea($data_textarea); echo br(1); if(!$this->input->post('desc')){ echo form_error('desc');}?></td> </tr> <tr> <td><?php echo form_label('Username:','username')?></td> <td><?php $data_input = array('class'=>'input-large', 'name'=>'username', 'id'=>'username', 'maxlength'=>'100'); echo form_input($data_input); ?> <span id="usr_verify" class="verify"></span><?php echo br(1); if(!$this->input->post('username')){ echo form_error('username');}?></td> </tr> <tr> <td><?php echo form_label('Password:','password')?></td> <td><?php $data_pass = array('class'=>'input-large', 'name'=>'password', 'id'=>'password', 'maxlength'=>'100', 'type'=>'password'); echo form_password($data_pass); echo br(1); if(!$this->input->post('password')){ echo form_error('password');}?></td> </tr> <tr> <td colspan="2"><center> <?php $submit_data = array('type'=>'submit', 'class'=>'white button', 'name'=>'submit_form', 'value'=>'Submit!'); echo form_submit($submit_data); $reset_data = array('type'=>'reset', 'class'=>'white button', 'name'=>'reset_form', 'value'=>'Reset!'); echo form_reset($reset_data);?></center> </td> </tr> <?php form_close();?> </table> </div> </div> [/code] I don't know where I go wrong, it could give an error message for require fields but for the other rules that I set especially to the user and password, it won't display an error message
  10. Having problems in dealing with flexigrid with a CRUD CodeIgniter implementation. I've just discovered the grocery CRUD already, but still... i'm confuse all about it.
  11. I'm just a newbie with this CodeIgniter framework and I'm currently working on a simple registration form. Right now, I have a difficulty in displaying css designs. Where would be my css folder will be placed that can have a short location in placing the href tag?
  12. How do the tumblr or wix site do the customizing stuff? what kind of language did they in building their own website builder, just like wix.com
  13. I'm planning to make a simple website wherein users can have their own page with the help of my web service. Right now, I'm quite confuse of would be the exact term of this kind of function, wherein a certain user's page template design can be changed by choosing different themes that's given by the web site. Best example would be the tumblr: I want to edit my tumblr site to be edited through uploading images in header, or... just use the random templates that's given by the tumblr themes.
  14. I already do the same method but it isn't successful.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.