Skip to content

Commit

Permalink
user info
Browse files Browse the repository at this point in the history
  • Loading branch information
cws13003 committed Dec 4, 2017
1 parent 14377c9 commit b69d77a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
29 changes: 29 additions & 0 deletions www/application/controllers/Tweet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

class Tweet extends CI_Controller {
function __Construct(){
parent::__Construct();
$this->load->database(); // load database
$this->load->model('User_Tweets_Model'); // load model
$this->output->enable_profiler(TRUE);
}

public function index(){
$this->load->helper('form');
$this->load->library('form_validation');

$data['title'] = 'Create a tweet';

$this->form_validation->set_rules('tweet', 'Tweet', 'required');

if ($this->form_validation->run() === FALSE)
{
$this->load->view('tweet', $data);
}
else
{
$this->User_Tweets_Model->addTweet();
$this->load->view('formsuccess');
}
}
}
23 changes: 23 additions & 0 deletions www/application/models/User_Info_Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
class User_Info_Model extends CI_Model {
// login
function getUserID(){

}
// new user
function addUser(){
$this->load->helper('url');

$data = array(
'first_name' => $this->input->post('firstname'),
'last_name' => $this->input->post('lastname'),
'email' => $this->input->post('email'),
'username' => $this->input->post('username'),
'password' => $this->input->post('password'),
'location' => $this->input->post('location')
);

return $this->db->insert('Users', $data);
}

}
18 changes: 18 additions & 0 deletions www/application/views/tweet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php $this->load->library('form_validation'); ?>
<?php echo validation_errors(); ?>
<?php echo form_open('tweet'); ?>

<h2><?php echo $title; ?></h2>

<div class="container">
<div class="row">
<div class="col-md-2 col-md-offset-5">
<h5>Tweet</h5>
<input type="text" name="tweet" value="<?php echo set_value('tweet'); ?>" size="50" />
<?php echo form_error('tweet'); ?>
<!--<input type="hidden" name="user_id" value="<?php echo 'id' // USER ID HERE for tweet creation ?>"/>-->
<div><input class="btn" type="submit" value="Submit"/></div>
</div>
</div>
</div>
</form>

0 comments on commit b69d77a

Please sign in to comment.