Welcome Guest, Not a member yet? Register   Sign In
To do a query before inserting data in mySQL
#1

[eluser]ambf[/eluser]
Hi!

I'm new here and need help ASAP!

I have a form and need to save it in the database. (Works fine!)
But before to save the new data in the database I need to run a query in the database to see if the email inserted at the form is already registered in the database.

How should I do the query??

here is my controller:


<?php

class Form extends Controller {


function form()
{
parent::Controller();
}



function display()
{
$data['query'] = $this->db->get('contact');
$this->load->view('display', $data);
}


function index()
{
$this->load->helper(array('form', 'url'));

$this->load->library('validation');

$rules['field_01'] = "required";
$rules['field_02'] = "required";
$rules['field_03'] = "required";
$rules['field_04'] = "required|valid_email";
$rules['field_05'] = "required|max_length[2]";
$rules['field_06'] = "required";
$rules['field_07'] = "required";



$this->validation->set_rules($rules);





if ($this->validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->db->insert('contact', $_POST);
$this->load->view('formsuccess', $_POST);
}
}
}
?>


Messages In This Thread
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 05:30 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 05:57 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 06:02 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 06:04 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 07:38 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 08:12 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 08:30 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 08:58 AM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 02:52 PM
To do a query before inserting data in mySQL - by El Forum - 11-02-2008, 06:32 PM
To do a query before inserting data in mySQL - by El Forum - 11-03-2008, 01:37 AM
To do a query before inserting data in mySQL - by El Forum - 11-03-2008, 02:02 AM
To do a query before inserting data in mySQL - by El Forum - 11-03-2008, 04:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB