Skip to content
Permalink
Browse files

Adaugat pagina de contact si modificat rutele

  • Loading branch information...
hopingsteam committed Jan 30, 2019
1 parent 4a13639 commit 184f4fb9e98136cedc5570e1d54e5205b736bc24
@@ -53,5 +53,11 @@
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['login'] = 'tutorial/login';
$route['register'] = 'tutorial/register';
$route['contact'] = 'tutorial/contact';
$route['dashboard'] = 'tutorial/index';
$route['logout'] = 'tutorial/logout';
$route['produs/:num'] = 'catalog/cauta_produs';
$route['produs/:num'] = 'Tutorial/functiaMihai';
@@ -0,0 +1,45 @@
<?php
class Tutorial extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper(array('url', 'form'));
$this->load->library('form_validation');
$this->load->model('user_model');
}
public function functiaMihai(){
$data = array(
'nume' => 'Popescu',
'prenume' => 'Andrei',
'username'=> 'uzerprietenos',
'parola' => 'parola1',
'email' => 'emailsmecher',
'rol' => 1,
);
$this->user_model->insereaza_utilizator($data);
}
public function updateazaUser(){
$data = array(
'nume' => 'Ilie',
'prenume' => 'Mihai',
);
$this->user_model->update_utilizator($data, 5);
}
public function stergeUser(){
$this->user_model->sterge_utilizator(5);
}
public function extrageUser(){
$result = $this->user_model->extrage_date(4);
echo $result[0]->prenume;
}
}
?>
@@ -6,8 +6,9 @@ public function __construct()
{
parent::__construct();
$this->load->helper(array('url', 'form'));
$this->load->library('form_validation');
$this->load->library(array('form_validation', 'email'));
$this->load->model('user_model');
$this->load->model('contact_model');
}
public function process_login(){
@@ -20,7 +21,7 @@ public function process_login(){
if ($this->form_validation->run() == FALSE)
{
$this->session->set_flashdata('msg', '<div class="alert alert-danger">Datele introduse sunt incorecte.</div>');
redirect("tutorial/login");
redirect("/login");
}
else
{
@@ -32,14 +33,15 @@ public function process_login(){
'uid' => $uresult[0]->ID,
'prenume' => $uresult[0]->prenume,
'nume' => $uresult[0]->nume,
'email' => $uresult[0]->email);
'email' => $uresult[0]->email,
'rol' => $uresult[0]->rol);
$this->session->set_userdata($sess_data);
redirect("tutorial/");
redirect("/dashboard");
}
else
{
$this->session->set_flashdata('msg', '<div class="alert alert-danger">Datele introduse sunt incorecte.</div>');
redirect("tutorial/login");
redirect("/login");
}
}
}
@@ -72,7 +74,66 @@ public function process_register() {
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Eroare!</div>');
redirect('tutorial/register');
}
}
public function process_contact() {
$this->form_validation->set_rules('name', 'Nume', 'trim|required|alpha|min_length[3]|max_length[30]');
$this->form_validation->set_rules('subject', 'Subiect', 'trim|required|alpha|min_length[3]|max_length[30]');
$this->form_validation->set_rules('email', 'E-Mail', 'trim|required|valid_email|min_length[3]|max_length[30]');
$this->form_validation->set_rules('message', 'Mesaj', 'trim|required|min_length[3]|max_length[30]');
if ($this->form_validation->run() == FALSE)
{
$this->session->set_flashdata('msg', '<div class="alert alert-danger">Nu ai respectat campurile.</div>');
redirect("/contact");
}
else
{
$contact_email = $this->input->post('email');
$contact_nume = $this->input->post('name');
$contact_subiect = $this->input->post('subject');
$contact_mesaj = $this->input->post('message');
$data = array(
'nume' => $contact_nume,
'email' => $contact_email,
'subiect' => $contact_subiect,
'mesaj' => $contact_mesaj
);
if ($this->contact_model->insereaza_contact($data))
{
$mesajComplet = nl2br($contact_mesaj);
$ipAddress = $this->input->ip_address();
$dataTrimitere = date("Y-m-d H:i");
$options = array(
'http' => array (
'header' => "Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: ".strlen(http_build_query($data))."\r\n".
"User-Agent:MyAgent/1.0\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$mesajComplet .= "Mesaj trimis de pe atestat in data de $dataTrimitere de pe IP: $ipAddress . Te pup!";
$this->email->from($contact_email, $contact_nume);
$this->email->to('whiteage13@yahoo.com');
$this->email->subject($contact_subiect);
$this->email->message($mesajComplet);
$this->email->send();
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">Ai trimis mesajul cu succes!</div>');
redirect('/contact');
}
else
{
// error
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Eroare!</div>');
redirect('/contact');
}
}
}
public function login() {
@@ -87,44 +148,28 @@ public function register() {
$this->load->view('templates/footer');
}
public function logout() {
$this->session->sess_destroy();
redirect('/login');
}
public function index() {
$data = new stdClass();
if($this->session->userdata('uid') == NULL)
show_404();
$data->rol = $this->session->userdata('rol');
$this->load->view('templates/header');
$this->load->view('pages/protected');
$this->load->view('pages/protected', $data);
$this->load->view('templates/footer');
}
public function functiaMihai(){
$data = array(
'nume' => 'Popescu',
'prenume' => 'Andrei',
'username'=> 'uzerprietenos',
'parola' => 'parola1',
'email' => 'emailsmecher',
'rol' => 1,
);
$this->user_model->insereaza_utilizator($data);
}
public function updateazaUser(){
$data = array(
'nume' => 'Ilie',
'prenume' => 'Mihai',
);
$this->user_model->update_utilizator($data, 5);
}
public function stergeUser(){
$this->user_model->sterge_utilizator(5);
}
public function extrageUser(){
$result = $this->user_model->extrage_date(4);
echo $result[0]->prenume;
public function contact() {
$this->load->view('templates/header');
$this->load->view('pages/contact');
$this->load->view('templates/footer');
}
}
?>
@@ -0,0 +1,9 @@
<?php
class Contact_model extends CI_Model
{
function insereaza_contact($data)
{
return $this->db->insert("contact", $data);
}
}
Oops, something went wrong.

0 comments on commit 184f4fb

Please sign in to comment.
You can’t perform that action at this time.