<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends CI_Model{
function __construct(){
$this->userTbl='login';
}
public function insert($data=array()){
if(!array_key_exists("created", $data)){
$data['created'] = date("Y-m-d H:i:s");
}
if(!array_key_exists("modified", $data)){
$data['modified'] = date("Y-m-d H:i:s");
}
$insert = $this->db->insert($this->userTbl, $data);
if($insert){
return $this->db->insert_id();;
}else{
return false;
}
}
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Users extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('form_validation');
$this->load->model('user');
}
/*
* User registration
*/
public function registration(){
$data=array();
$userData=array();
if($this->input->post(regisSubmit)){
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|callback_email_check');
$this->form_validation->set_rules('password', 'password', 'required');
$this->form_validation->set_rules('conf_password', 'confirm password', 'required|matches[password]');
}
$userData=array(
'name'=>strip_tags($this->input->post('name')),
'email'=>strip_tags($this->input->post('email')),
'password'=>strip_tags($this->input->post('password')),
'gender'=>strip_tags($this->input->post('gender')),
'phone'=>strip_tags($this->input->post('phone'))
);
if($this->form_validation->run()==true){
$insert=$this->user->insert($userData);
if($insert){
$this->session->set_userdata('success_msg', 'Your registration was successfully. Please login to your account.');
redirect(users/login);
}
else{
$data['error_msg']='Try again';
}
}
}
$data['user'] = $userData;
//load the view
$this->load->view('users/registration', $data);
}
<!DOCTYPE html>
<html lang="en">
<head>
<link href="<?php echo base_url(); ?>assets/css/style.css" rel='stylesheet' type='text/css' />
</head>
<body>
<div class="container">
<h2>User Registration</h2>
<form action="" method="post">
<div class="form-group">
<input type="text" class="form-control" name="name" placeholder="Name" required="" value="<?php echo !empty($user['name'])?$user['name']:''; ?>">
<?php echo form_error('name','<span class="help-block">','</span>'); ?>
</div>
<div class="form-group">
<input type="email" class="form-control" name="email" placeholder="Email" required="" value="<?php echo !empty($user['email'])?$user['email']:''; ?>">
<?php echo form_error('email','<span class="help-block">','</span>'); ?>
</div>
<div class="form-group">
<input type="text" class="form-control" name="phone" placeholder="Phone" value="<?php echo !empty($user['phone'])?$user['phone']:''; ?>">
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="Password" required="">
<?php echo form_error('password','<span class="help-block">','</span>'); ?>
</div>
<div class="form-group">
<input type="password" class="form-control" name="conf_password" placeholder="Confirm password" required="">
<?php echo form_error('conf_password','<span class="help-block">','</span>'); ?>
</div>
<div class="form-group">
<?php
if(!empty($user['gender']) && $user['gender'] == 'Female'){
$fcheck = 'checked="checked"';
$mcheck = '';
}else{
$mcheck = 'checked="checked"';
$fcheck = '';
}
?>
<div class="radio">
<label>
<input type="radio" name="gender" value="Male" <?php echo $mcheck; ?>>
Male
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="gender" value="Female" <?php echo $fcheck; ?>>
Female
</label>
</div>
</div>
<div class="form-group">
<input type="submit" name="regisSubmit" class="btn-primary" value="Submit"/>
</div>
</form>
<p class="footInfo">Already have an account? Login here</p>
</div>
</body>
</html>
Here in this form I need to insert data into mysql database using codeigniter. but the data is not inserting into the database and also not showing any error. Below is the code for modal, controller and view page. In database.php file, eerything is fine. Here in this, How to debug the code, and what is the error. Thanks in advance.
Define url in routes.php
$route['user/registration'] = 'Users/registration';
also define your project base_url in config/config.php file
use
form action="user/registration"
method="post">
instead of
form action="" method="post">
and view file in
<input type="text" class="form-control" name="name" placeholder="Name" required="" value="<?php echo !empty($user['name'])?$user['name']:''; ?>">
<?php echo form_error('name','<span class="help-block">','</span>'); ?>
change to:
<input type="text" class="form-control" name="name" placeholder="Name" required="" value="<?php echo isset($user['name']) ? $user['name']:''; ?>">
<?php echo form_error('name','<span class="help-block">','</span>'); ?>
You never post anything to your controller. look at this line of your view file.
<form action="" method="post">
Change to :
<form action="<?php echo base_URL(); ?>Users/registration" method="post">
Related
Form validation and record insert not working in codeigniter
model
class Mymodel extends CI_Model
{
function insert($data)
{
$this->db->insert("users", $data);
}
}
controller
defined('BASEPATH') OR exit('No direct script access allowed');
class Mycontroller extends CI_controller
{
function index()
{
$this->load->view('myfolder/my_page');
}
function login()
{
$this->load->view('myfolder/login');
}
function signup()
{
$this->load->view('myfolder/signup');
}
function signupmethod()
{
$this->load->library('form_validation');
$this->form_validation->set_rules("firstname","First Name",'requird|alpha');
$this->form_validation->set_rules("lastname","Last Name",'requird|alpha');
$this->form_validation->set_rules("email","Email",'requird|alpha');
$this->form_validation->set_rules("password","Password",'requird|alpha');
$this->form_validation->set_rules("mobile","Mobile",'requird|alpha');
if ($this->form_validation->run())
{
$this->load->model("mymodel");
$data = array(
"firstname" => $this->input->post("firstname"),
"lastname" => $this->input->post("lastname"),
"email" => $this->input->post("email"),
"password" => $this->input->post("password"),
"mobile" => $this->input->post("mobile"),
"curtime" => "NOW()"
);
if($this->input->post("Signup"))
{
$this->mymodel->insert($data);
redirect(base_url() . "mycontroller/Inserted");
}
}
}
public function Inserted()
{
$this->index();
}
}
?>
view(html code)
<?php include('header.php'); ?>
<form method="post" action="<?php echo base_url()?>mycontroller/signupmethod" enctype="multipart/form-data">
<div class="container">
<div class="row">
<h3>Login</h3>
</div>
<div class="row">
<div class="col-md-6 form-group">
<label>First Name</label>
<input type="text" name="firstname" value="" class="form-control">
<span class="text-danger"><?php echo form_error("firstname"); ?></span>
</div>
<div class="col-md-6 form-group">
<label>Last Name</label>
<input type="text" name="lastname" value="" class="form-control">
<span class="text-danger"><?php echo form_error("lastname"); ?></span>
</div>
</div>
<div class="row">
<div class="col-md-6 form-group">
<label>Email</label>
<input type="text" name="email" value="" class="form-control">
<span class="text-danger"><?php echo form_error("email"); ?></span>
</div>
<div class="col-md-6 form-group">
<label>Password</label>
<input type="password" name="password" value="" class="form-control">
<span class="text-danger"><?php echo form_error("password"); ?></span>
</div>
</div>
<div class="row">
<div class="col-md-6 form-group">
<label>Mobile</label>
<input type="text" name="mobile" value="" class="form-control">
<span class="text-danger"><?php echo form_error("mobile"); ?></span>
</div>
<div class="col-md-6 form-group" style="margin-top: 23px;">
<input type="submit" name="submit" value="Signup" class="btn btn-info">
</div>
</div>
I have read every line carefully, code run but no errors showing and validation and record insert are not working. and no errors showing.
please help.
Change controller this block of code when you fetch form elements in controller always use the element name
if($this->input->post("submit"))
{
$this->mymodel->insert($data);
redirect(base_url() . "mycontroller/Inserted");
}
Correct spelling of required
$this->form_validation->set_rules("firstname","First Name",'required|alpha');
Your set_rules statements are incorrect. Use required instead of requird otherwise set_rules will fail.
When you are not sure why form_validation is failing, try getting the errors with:
If($this->form_validation->run() == false)
{
echo validation_error();
}
I need to validate a user form, which I am trying to submit after taking the input in view named as 'home.php', where I have specified the base_url('Home/user_validation').
With Home is name of the controller and user_validation is the method name. I tried to figure out the issue but I could not understand why not any other function is being invoked apart from index function in Home controller. Please help me in this case.
Controller Home.php
public function user_validation()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'trim|required');
$this->form_validation->set_rules('password', 'Password', 'trim|required');
if ($this->form_validation->run() == FALSE) {
$this->session->set_flashdata('message', 'Invalid username and password.');
redirect('home');
}
else {
$user_name123 = $this->input->post('username');
$teacher = $this->input->post('remember');
if ($user_name123 == 'admin') {
$query = $this->login_model->validate();
echo("Logged in");
}
}
}
Model login_model.php
function validate()
{
$this->db->where('admin_username', $this->input->post('username'));
$this->db->where('admin_password', $this->input->post('password'));
$this->db->where('active_status', 'Yes');
$query = $this->db->get('cis_tbl_admin');
if ($query->num_rows() == 1) {
return true;
}
else {
return false;
}
}
View home.php
<form action="<?php echo base_url('Home/user_validation') ?>" method="post" id="instantform">
<fieldset>
<div class="input-prepend" title="Username" data-rel="tooltip">
<span class="add-on"><i class="icon-user"></i></span>
<input autofocus class="input-large span10"
name="username" id="username" type="text"
placeholder="user name"/>
</div>
<div class="clearfix"></div>
<div class="input-prepend" title="Password" data-rel="tooltip">
<span class="add-on"><i class="icon-lock"></i></span>
<input class="input-large span10" name="password"
id="password" type="password"
placeholder="password" autocomplete="off"/>
</div>
<div class="clearfix"></div>
<div class="input-prepend">
<label class="remember" for="remember">
<input type="checkbox" name="remember" id="remember"
value="teacher"/>Teacher Login</label>
</div>
<div class="clearfix"></div>
<p class="center span5">
<button type="submit" name="submit" id="submit" class="btn btn-primary">Login</button>
<br/><br/>
<!--<a class="ajax-link" href="<?php echo base_url(); ?>parent_info/get_students_info"> <span class="hidden-tablet">Parent Login</span></a>-->
</p>
</fieldset>
<input type="hidden" name="sys_date" id="sys_date" value="<?php echo $sys_date; ?>">
<input type="hidden" name="sys_time" id="sys_time" value="<?php echo $sys_time; ?>">
<input type="hidden" name="details" id="details" value="<?php echo $details; ?>">
</form>
Check your config routes file to be sure you call functions of the home controller:
$route['Home/(:any)'] = 'Home/$1';
I have a dynamic form that is generated depending on how many people are selected from another page. When I submit this form however, the form validation fails without giving me an error. Could someone take a look and see why it's failing? I have tried debugging it but I can't see it. Maybe my method is wrong? This form used to work as well. It started to not work after I added the form processing for the children. Hopefully someone can help. Thank you so much.
Controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Details extends TX_Controller {
public function __construct(){
parent::__construct();
ini_set('memory_limit', '64M');
$this->load->model('TransactionsModel');
$this->load->model('ProductsModel');
}
public function index(){
$data['productdetail'] = $this->ProductsModel->getProduct($this->session->userdata('productid'));
// var_dump($data['productdetail']);
$data['adults'] = $this->session->userdata('adults');
$data['children'] = $this->session->userdata('children');
$this->load->view('public/publicMenu/navigationLink');
$this->load->view('public/publicDetails/details',$data);
$this->load->view('public/publicMenu/navigationJquery');
}
public function next(){
$adultlength = $this->input->post('adults');
$childrenlength = $this->input->post('children');
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
for ($i=0; $i < $adultlength; $i++) {
$this->form_validation->set_rules('inputfirstname['.$i.']', 'Firstname', 'trim|required');
$this->form_validation->set_rules('inputlastname['.$i.']', 'Lastname', 'trim|required');
$this->form_validation->set_rules('inputdateofbirth['.$i.']', 'Date of Birth', 'trim|required');
$this->form_validation->set_rules('inputicnumber['.$i.']', 'IC Number', 'trim|required');
$this->form_validation->set_rules('inputmobilenumber['.$i.']', 'Mobile Number', 'trim|required');
$this->form_validation->set_rules('inputemail['.$i.']', 'Email', 'trim|required');
$this->form_validation->set_rules('inputconfirmemail['.$i.']', 'Confirm Email', 'trim|required');
$inputfirstname[] = $this->input->post('inputfirstname['.$i.']');
$inputlastname[] = $this->input->post('inputlastname['.$i.']');
$inputdateofbirth[] = $this->input->post('inputdateofbirth['.$i.']');
$inputicnumber[] = $this->input->post('inputicnumber['.$i.']');
$inputmobilenumber[] = $this->input->post('inputmobilenumber['.$i.']');
$inputemail[] = $this->input->post('inputemail['.$i.']');
$inputpostcode[] = $this->input->post('inputpostcode['.$i.']');
}
for($j=0;$j<$childrenlength;$j++){
$inputchildfirstname[] = $this->input->post('inputchildfirstname['.$j.']');
$inputchildlastname[] = $this->input->post('inputchildlastname['.$j.']');
$inputchilddateofbirth[] = $this->input->post('inputchilddateofbirth['.$j.']');
}
if($this->form_validation->run()==false){
$data['productdetail'] = $this->ProductsModel->getProduct($this->session->userdata('productid'));
$data['adults'] = $this->session->userdata('adults');
$data['children'] = $this->session->userdata('children');
$this->load->view('public/publicMenu/navigationLink');
$this->load->view('public/publicDetails/details',$data);
$this->load->view('public/publicMenu/navigationJquery');
}else{
for ($i=0; $i < $adultlength; $i++) {
$passengerdetails[] = array(
'firstname'=>$inputfirstname[$i],
'lastname'=>$inputlastname[$i],
'dateofbirth'=>$inputdateofbirth[$i],
'icnumber'=>$inputicnumber[$i],
'mobilenumber'=>$inputmobilenumber[$i],
'email'=>$inputemail[$i],
'postcode'=>$inputpostcode[$i],
'usertype'=>'adult'
);
}
if($childrenlength>0){
for($j=0;$j<$childrenlength;$j++){
$childpassengerdetails[] = array(
'firstname'=>$inputchildfirstname[$j],
'lastname'=>$inputchildlastname[$j],
'dateofbirth'=>$inputchilddateofbirth[$j],
'icnumber'=>'',
'mobilenumber'=>'',
'email'=>'',
'postcode'=>'',
'usertype'=>'child'
);
}
$this->session->set_userdata('childpassengerdetails',json_encode($childpassengerdetails));
}
$this->session->set_userdata('passengerdetails',json_encode($passengerdetails));
redirect('/Public/Payment');
}
}
}
View
<section id="about" class="container content-section text-center">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<h2><?php echo $productdetail->name;?></h2>
<h2>Enter Passenger Details</h2>
<?php echo form_open_multipart('Public/Details/next','class="inputform"');?>
<h3>Adults</h3>
<?php for($i=0;$i<$adults;$i++){?>
<input type="hidden" class="form-control" name="adult" value="<?php echo $adults;?>">
<label for="inputfirstname">Firstname</label>
<input type="text" class="form-control" name="inputfirstname[]" placeholder="Firstname" value="<?php echo set_value('inputfirstname['.$i.'],""');?>">
<div class="errormessage"><?php echo form_error('inputfirstname['.$i.']'); ?></div>
<label for="inputfirstname">Lastname</label>
<input type="text" class="form-control" name="inputlastname[]" placeholder="Lastname" value="<?php echo set_value('inputlastname[$i]');?>">
<div class="errormessage"><?php echo form_error('inputlastname['.$i.']'); ?></div>
<label for="inputdateofbirth">Date of Birth</label>
<input type="date" class="form-control" name="inputdateofbirth[]" value="<?php echo set_value('inputdateofbirth[$i]');?>">
<div class="errormessage"><?php echo form_error('inputdateofbirth['.$i.']'); ?></div>
<label for="inputicnumber">IC Number</label>
<input type="text" class="form-control" name="inputicnumber[]" placeholder="IC Number" value="<?php echo set_value('inputicnumber[$i]');?>">
<div class="errormessage"><?php echo form_error('inputicnumber['.$i.']'); ?></div>
<label for="inputmobilenumber">Mobile Number</label>
<input type="text" class="form-control" name="inputmobilenumber[]" placeholder="Mobile Number" value="<?php echo set_value('inputmobilenumber[$i]');?>">
<div class="errormessage"><?php echo form_error('inputmobilenumber['.$i.']'); ?></div>
<label for="inputemail">Email</label>
<input type="text" class="form-control" name="inputemail[]" placeholder="Email" value="<?php echo set_value('inputemail[$i]');?>">
<div class="errormessage"><?php echo form_error('inputemail['.$i.']'); ?></div>
<label for="inputconfirmemail">Confirm Email</label>
<input type="text" class="form-control" name="inputconfirmemail[]" placeholder="Confirm Email" value="<?php echo set_value('inputconfirmemail[$i]');?>">
<div class="errormessage"><?php echo form_error('inputconfirmemail['.$i.']'); ?></div>
<label for="inputaddress1">Address</label>
<input type="text" class="form-control" name="inputaddress1[]" placeholder="Address 1" value="<?php echo set_value('inputaddress1[$i]');?>">
<input type="text" class="form-control" name="inputaddress2[]" placeholder="Address 2" value="<?php echo set_value('inputaddress2[$i]');?>">
<input type="text" class="form-control" name="inputaddress3[]" placeholder="Address 3" value="<?php echo set_value('inputaddress3[$i]');?>">
<input type="text" class="form-control" name="inputaddress4[]" placeholder="Address 4" value="<?php echo set_value('inputaddress4[$i]');?>">
<input type="text" class="form-control" name="inputaddress5[]" placeholder="Address 5" value="<?php echo set_value('inputaddress5[$i]');?>">
<label for="inputpostcode">Postcode</label>
<input type="text" class="form-control" name="inputpostcode[]" placeholder="Postcode1" value="<?php echo set_value('inputpostcode[$i]');?>">
<div class="errormessage"><?php echo form_error('inputpostcode['.$i.']'); ?></div>
<?php } ?>
<?php if($children>0){ ?>
<h3>Children</h3>
<?php for($j=0;$j<$children;$j++){ ?>
<input type="hidden" class="form-control" name="children" value="<?php echo $children;?>">
<label for="inputchildfirstname">Firstname</label>
<input type="text" class="form-control" name="inputchildfirstname[]" value="<?php echo set_value('inputchildfirstname[$j]');?>" placeholder="Firstname">
<label for="inputchildlastname">Lastname</label>
<input type="text" class="form-control" name="inputchildlastname[]" value="<?php echo set_value('inputchildlastname[$j]');?>" placeholder="Lastname">
<label for="inputchilddateofbirth">Date of Birth</label>
<input type="date" class="form-control" name="inputchilddateofbirth[]" value="<?php echo set_value('inputchilddateofbirth[$j]');?>">
<?php }} ?>
<p><button type="submit" class="btn btn-primary">Next</button></p>
<p>Cancel</p>
<?php echo form_close(); ?>
<p><?php echo $this->session->flashdata('Form'); ?></p>
</div>
</div>
</section>
I am trying to insert the data to the database by php CodeIgniter and display the result in the same page during submit the button. Below is my code.The problem is i got an error message as Duplicate entry '104' for key 'PRIMARY'. Please help. View Page
<div class="container col-lg-4">
<?php echo validation_errors(); ?>
<form action="<?php echo base_url();?>index.php/Welcome/gallery1" method="post">
<div class="form-group has-info">
<?php
foreach ($h->result_array() as $value){
?>
<input type="hidden" name="id" value="<?php echo $value['offer_id'];?>" >
<?php }?>
<br>
<label class="control-label col-lg-6" for="inputSuccess">Offer title</label>
<input type="text" class="form-control col-lg-6" name="offered" id="offered" value="<?php if(isset($_POST['offered'])) echo $_POST['offered']; ?>">
<label class="control-label col-lg-6" for="inputSuccess">Offer Description</label>
<textarea id="description" name="description" class="form-control col-lg-6" rows="3" value="<?php if(isset($_POST['description'])) echo $_POST['description']; ?>" ></textarea>
<br/>
<div>
<button type="submit" class="btn btn-primary col-lg-4"> <span>SUBMIT</span>
</button>
</div>
</div>
</form>
Controller page
public function gallery1()
{
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->model('Login_set');
$this->form_validation->set_rules('id','id');
$this->form_validation->set_rules('offered','offered','required');
$this->form_validation->set_rules('description','description','required');
$page_id =$this->uri->segment(3);
$data['h']=$this->Login_set->select();
$this->load->view('App_stay/pages/hotel1_galery.php',$data);
if($this->form_validation->run() == FALSE)
{
}
else
{
$data['query']=$this->Login_set->add_offer();
if($data['query']!=NULL)
{
$data['ins_msg']='data inserted';
}
else
{
$data['ins_msg']='data not inserted';
}
}
}
Model Page
public function add_offer()
{
$this->form_validation->set_message('offered','offered','required');
$this->form_validation->set_message('description','description','required');
$this->load->database();
$this->load->helper('url');
$data=array
(
'offer_id'=>$this->input->post('id'),
'hotel_id'=>1,
'offers_name'=>$this->input->post('offered'),
'offers_description'=>$this->input->post('description')
);
$this->db->insert('offer_hotel1',$data);
}
I've been building a site recently for a friend and I've gotten stuck on this one form. A button links to url in which this form is on and then once you fill out all the information and click submit, instead of returning you back to home.php it just removes the form from view and all you see is a blank new.php and it doesn't submit the information.
<?php
function renderForm($user, $rank, $position, $error)
{
?>
<?php
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<center>
<form action="" method="post">
<div class="form-group">
<label for="username">Username*</label>
<input id="username" class="form-control" type="text" name="user" placeholder="Username" value="<?php echo $user; ?>" />
</div>
<div class="form-group">
<label for="rank">Rank</label>
<select class="form-control" name="rank">
<option value="1">Pending Rank</option>
<option value="2">PVT</option>
</select>
</div>
<div class="form-group">
<label for="position">Position</label>
<input id="position" class="form-control" type="text" name="position" placeholder="MOG/GG" value="<?php echo $position; ?>" />
</div>
<div class="form-group">
<label for="Date">Date*</label>
<input id="Date" class="form-control" type="text" name="date" placeholder="<?php echo date('d M y'); ?>" value="<?php echo $date; ?>" />
</div>
<div class="form-group">
<label for="Tag">Tag*</label>
<input id="Tag" class="form-control" type="text" name="tag" placeholder="[]" value="<?php echo $tag; ?>" />
</div>
<div class="form-group">
<label for="adt">ADT</label>
<input id="adt" class="form-control" type="text" name="adt" placeholder="{TEST}" value="<?php echo $adt; ?>" />
</div>
<div class="form-group">
<label for="exp">EXP</label>
<input id="exp" class="form-control" type="text" name="exp" placeholder="420" value="<?php echo $exp; ?>" />
</div>
<div class="form-group">
<label for="reg">Regiment</label>
<input id="reg" class="form-control" type="text" name="reg" placeholder="[P]" value="<?php echo $reg; ?>" />
</div>
<div class="form-group">
<label for="Notes">Notes</label>
<input id="Notes" class="form-control" type="text" name="notes" placeholder="Notes" value="<?php echo $notes; ?>" />
</div>
<button type="submit" name="submit" class="btn btn-default" value="Submit">Submit</button>
</form>
<script>
$('.modal').on('hidden.bs.modal', function(){
$(this).find('form')[0].reset();
});
</script>
<?php
}
include('config/db.php');
if (isset($_POST['submit']))
{
$user = mysql_real_escape_string(htmlspecialchars($_POST['user']));
$rank = mysql_real_escape_string(htmlspecialchars($_POST['rank']));
$position = mysql_real_escape_string(htmlspecialchars($_POST['position']));
$date = mysql_real_escape_string(htmlspecialchars($_POST['date']));
$tag = mysql_real_escape_string(htmlspecialchars($_POST['tag']));
$adt = mysql_real_escape_string(htmlspecialchars($_POST['adt']));
$exp = mysql_real_escape_string(htmlspecialchars($_POST['exp']));
$reg = mysql_real_escape_string(htmlspecialchars($_POST['reg']));
$notes = mysql_real_escape_string(htmlspecialchars($_POST['notes']));
$datej = mysql_real_escape_string(htmlspecialchars($_POST['date']));
if ($user == '' || $rank == '' || $date == '' || $tag == '')
{
$error = '<center>ERROR: Please fill in all required fields!</center>';
#renderForm($user, $rank, $position, $error);
}
else
{
mysql_query("INSERT per SET user='$user', rank='$rank', position='$position', date='$date', tag='$tag', adt='$adt', exp='$exp', reg='$reg', notes='$notes', datej='$datej'", $db1)
or die(mysql_error());
include('logsadd.php');
write_mysql_log('has added member <font color="black"><b>'. $user .'</b></font>.', $db);
header("Location: home.php");
}
}
else
header("home.php");
{
#renderForm('','','');
}?>
Your else looks like this
else
header("home.php");
{
#renderForm('','','');
it should be
else
{
// header should be inside the else part
header("Location:home.php");
#renderForm('','','');