I'm very new to php. when I try to register a form through php. the data
s are submitted to database but the redirection to a particular page is failed.
I have my login form named as index.php in root directory. and my registration form in second level directory. and my registration form control is in first level of directory. I used php_fetch for url sanitize. Here is my folder structure -
root->inc(folder)
->index.php
inc(folder)->pages(folder)
->registration.con.php
pages(folder)->registrster.php
here is my form controls
<form class="js-validation-register form-horizontal push-50-t push-50" action="<?php echo esc_url($_SERVER['PHP_SELF']); ?>" method="post" name="registration_form">
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="text" id="username" name="username" placeholder="Please enter a username">
<label for="username">Username</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="email" id="email" name="email" placeholder="Please provide your email">
<label for="email">Email</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="password" id="password" name="password" placeholder="Choose a strong password..">
<label for="password">Password</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="password" id="confirmpwd" name="confirmpwd" placeholder="..and confirm it">
<label for="register-password2">Confirm Password</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label class="css-input switch switch-sm switch-success">
<input type="checkbox" id="register-terms" name="register-terms"><span></span> I agree with terms & conditions
</label>
</div>
</div>
<div class="form-group">
<div class="col-xs-12 col-sm-6 col-md-5">
<input class="btn btn-block btn-success" type="button"
value="Register"
onclick="return regformhash(this.form,
this.form.username,
this.form.email,
this.form.password,
this.form.confirmpwd);" />
</div>
</div>
</form>
here is my php_fwtch function
function esc_url($url) {
if ('' == $url) {
return $url;
}
$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%#$\|*\'()\\x80-\\xff]|i', '', $url);
$strip = array('%0d', '%0a', '%0D', '%0A');
$url = (string) $url;
$count = 1;
while ($count) {
$url = str_replace($strip, '', $url, $count);
}
$url = str_replace(';//', '://', $url);
$url = htmlentities($url);
$url = str_replace('&', '&', $url);
$url = str_replace("'", ''', $url);
if ($url[0] !== '/') {
// We're only interested in relative links from $_SERVER['PHP_SELF']
return '';
} else {
return $url;
}
}
as you can see when i register a form on success it should redirect me to ../../index.php but insted it redirects me to ../index.php where registeration.con.php and functions exsits..!
this error is im getting on sucessful registration..
Not Found
The requested URL /src3/inc/index.php was not found on this server.
i know it is redirecting to index page on inc folder.. but i have to redirect it to index page on the root directory..
please help me..
Related
myiamge
I have 2 forms as tab in signup page when one form is submit and if have any error I want to redirect to that specific tab which have error but did not happen.
Here is my view
<?php include 'header.php'; ?>
<section class="services">
<div class="container">
<div class="signup-wrapper well" style="margin-bottom: 80px; margin-top: 80px;">
<div class="container">
<div class="services__main">
<h2 class="title title--main"><span class="title__bold">Sign Up</span><span class="line line--title"><span class="line__first"></span><span class="line__second"></span></span></h2>
</div>
<div class="aside-tabs__links">
Genrel User
Dealership
</div>
<div class="aside-tabs__blocks about-tab js-tab-block no-b-border" id="desc" >
<div class="col-md-5">
<form action="<?= base_url();?>Home/add_user" method="post" >
<!-- class="quick-form" -->
<div class="form-group">
<input type="text" class="form-control" name="fname" placeholder="Full Name" />
</div>
<?php echo form_error('fname'); ?>
<div class="form-group">
<input type="email" class="form-control" name="email" placeholder="Email" />
</div>
<?php echo form_error('email'); ?>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="Password" />
</div>
<?php echo form_error('password'); ?>
<div class="form-group">
<input type="text" class="form-control" name="phone" placeholder="Phone #" />
</div>
<?php echo form_error('phone'); ?>
<div class="form-group">
<select class="select-2 form-control" name="city">
<option>Select City</option>
<?php foreach ($results as $result) { ?>
<option><?= $result->city; ?></option>
<?php } ?>
</select>
</div>
<?php echo form_error('city'); ?>
<div class="form-group">
<input type="submit" class="btn button button--red button--main pull-right" style="margin-bottom: 10px;" value="Sign Up">
</div>
</form>
</div>
</div>
<div class="aside-tabs__blocks about-tab js-tab-block no-b-border" id="rev" style="display: none;">
<div class="col-xs-5">
<form action="<?= base_url();?>Home/add_dealer" method="post" enctype="multipart/form-data">
<h4>Comapny Information</h4>
<hr>
<div class="form-group">
<input type="text" class="form-control" name="cname" placeholder="Company Name" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="owner" placeholder="Owner Name" />
</div>
<div class="form-group">
<select class="select-2 form-control" name="city">
<option>Select City</option>
<?php foreach ($results as $result) { ?>
<option><?= $result->city; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<input type="text" class="form-control" name="address" placeholder="Office Location" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="phone" placeholder="Office Phone" />
</div>
<div class="form-group">
<select name="business-type" class="form-control">
<option class="form-group">Products Deal</option>
<option class="form-group">Bikes</option>
<option class="form-group">Accessories</option>
<option class="form-group">Both</option>
</select>
</div>
<div class="form-group">
<input type="text" class="form-control" name="link" placeholder="social-link(optional)" />
</div>
<div class="form-group">
<button type="button" class="button button--custom--grey button--main btn" id="logo">Upload Logo</button>
<input type="file" class="form-control hidden" id="logo1" name="logo1" /><span id="mylogo">* Format must be jpg,jpeg or png</span>
</div>
<?php echo form_error('logo'); ?>
<div class="form-group">
<textarea class="form-control" name="descrp" placeholder="Description(optional)"></textarea>
</div>
<h4>Primary Information</h4>
<hr>
<div class="form-group">
<input type="text" class="form-control" name="email" placeholder="Email" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="password" placeholder="Password" />
</div>
<div class="form-group">
<input type="submit" name="submit" class="btn button button--red button--main pull-right" value="Sign Up">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
<?php include 'footer.php'; ?>
here is my controller
function add_dealer()
{
//echo "<pre>"; print_r($_FILES);
$config['upload_path'] = 'C:\xampp\htdocs\devilbirds\images\uploads';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['encrypt_name'] = 'TRUE';
$config['overwrite'] = 'FALSE';
$config['wm_text'] = 'Deveil Birds';
$config['wm_type'] = 'text';
$config['wm_font_path'] = 'C:\xampp\htdocs\devilbirds/fonts/fontawesome-webfont.ttf';
$config['wm_font_size'] = '16';
$config['wm_font_color'] = 'aabbcc';
$config['wm_vrt_alignment'] = 'bottom';
$config['wm_hor_alignment'] = 'center';
$config['wm_padding'] = '20';
$this->load->library('upload', $config);
$this->image_lib->watermark();
$abc = $this->upload->do_upload('logo1');
$upload_data = $this->upload->data();
// var_dump($abc);exit();
$file_name = $upload_data['file_name'];
$this->form_validation->set_rules('cname','CName','trim|required');
$this->form_validation->set_rules('logo1','Logo1','trim');
$this->form_validation->set_rules('address','Address','trim');
$this->form_validation->set_rules('phone','Phone','trim|is_unique[bd_dealer.phone]');
$this->form_validation->set_rules('owner','Owner','trim');
$this->form_validation->set_rules('descrp','Descrp','trim');
$this->form_validation->set_rules('business-type','Business-type','trim');
$this->form_validation->set_rules('link','Link','trim');
$this->form_validation->set_rules('email','Email','trim|is_unique[bd_dealer.email]');
$this->form_validation->set_rules('password','Password','trim|min_length[5]|max_length[20]');
$this->form_validation->set_rules('city','City','trim');
if ($this->form_validation->run() == FALSE)
{
$data['error'] = $this->session->set_flashdata('errors');
$this->load->view('pages/signup',$data);// this is the link which loads my view i dont get how to go load that specific div from this url
}
else
{
$userData = array(
'company' => $this->input->post('cname'),
'logo' => $file_name,
'location' => $this->input->post('address'),
'phone' => $this->input->post('phone'),
'name' => $this->input->post('owner'),
'description' => $this->input->post('descrp'),
'business_type' => $this->input->post('business-type'),
'social_link' => $this->input->post('link'),
'email' => $this->input->post('email'),
'password' => $this->input->post('password'),
'city' => $this->input->post('city'));
$data = array(
'email' => $this->input->post('email'),
'password' => $this->input->post('password'),
'user_type' => '2');
//var_dump($userData);exit();
$this->Home_m->add_dealer($userData);
$this->Home_m->users($data);
redirect('Home/login');
}
}
I have two functions for two different forms in tabs. let suppose if i post my dealer form and this form have any issue then it will redirect to the signup page and it shows the pre-active tab which is general user signup. i want to redirect to the div that contain the form or dealer signup. any help will be appreciated , thanks in advance
In your controller when you get error do this.
for form one error
$data['error'] = $this->session->set_flashdata('errors');
$data['div1'] = "div1";
$this->load->view('pages/signup',$data);// this is the link which loads my view i dont get how to go load that specific div from this url ,i have pass div1 as parameter
For form two error
$data['error'] = $this->session->set_flashdata('errors');
$data['div2'] = "div2";
$this->load->view('pages/signup',$data);// this is the link which loads my view i dont get how to go load that specific div from this url ,i have pass div1 as parameter
In your view page
<script>
$(document).ready(function(){
var div1 = "<?php $div1; ?>";
var div2 = "<?php $div2; ?>";
if(div1=='' && div2==''){
$("#desc").show();
$("#rev").hide();
}else if(div1=='div1' && div2==''){
$("#desc").show();
$("#rev").hide();
}else if(div1=='' && div2=='div2'){
$("#desc").hide();
$("#rev").show();
}
})
</script>
div1
<div class="aside-tabs__blocks about-tab js-tab-block no-b-border" id="desc">
Div2
<div class="aside-tabs__blocks about-tab js-tab-block no-b-border" id="rev">
I hope it will help you.
My site was working just fine, no issues, then all of a sudden I receive error "An Error Was Encountered - The action you have requested is not allowed" during every form submit.
I am using Codeigniter 3 with SSL and I have CSRF protection turned on. I did not change anything lately so I have no idea why my site stopped working. If I turn CSRF off, form submission works fine.
Settings
$config['base_url'] = 'https://www.mywebsite.com';
$config['index_page'] = '';
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '.mywebsite.com';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'msmm_tn';
$config['csrf_cookie_name'] = 'msmm_cn';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
Form
<form action="https://www.mywebsite.com/" class="navbar-form navbar-left" id="search" method="post" accept-charset="utf-8">
<input type="hidden" name="msmm_tn" value="caeea1bc65c09f29691a1a692e09a30a" style="display:none;" />
<input type="hidden" name="token" value="ada2832a" style="display:none;" />
<input type="hidden" name="date-search-form" id="date-search-form" value="X">
<div class="form-group">
<input type="date" class="form-control input-md" name="from_date" id="from_date" value="2017-08-15" />
</div>
<div class="form-group">
<input type="date" class="form-control input-md" name="to_date" id="to_date" value="2017-08-16" />
</div>
<div class="form-group">
<input type="search" class="form-control input-md" name="search_text" id="search_text" placeholder="Search" value="">
</div>
<div class="form-group">
<button type="submit" class="btn btn-default btn-sm" name="go" id="go"><i class="fa fa-search" aria-hidden="true"></i>
</button>
</div>
</form>
</div>
Server side form code:
<?php
$attributes = array('class' => 'form-horizontal', 'id' => 'signup');
echo form_open('', $attributes);
?>
<?php
if( isset( $login_error_mesg ) )
{
echo '<div class="alert alert-danger input_bump" role="alert">';
echo 'Invalid Username, Email Address, or Password.<br>Username, email address and password are all case sensitive.';
echo '</div>';
}
if( $this->input->get('logout') )
{
echo '<div class="alert alert-success input_bump text-center" role="alert"><p>You have successfully logged out.</p></div>';
}
?>
<div class="form-group form-padding">
<label class="form-label" for="login_name">User Name or Email</label>
<input type="text" class="form-control form-fixer input-md" name="login_string" id="login_string" value="<?php echo $this->input->post('login_string'); ?>">
</div>
<div class="form-group form-padding">
<label class="form-label" for="pwd">Password</label>
<input type="password" class="form-control input-md" id="login_pass" name="login_pass" maxlength="<?php echo config_item('max_chars_for_password'); ?>" autocomplete="off" />
</div>
<div class="input_bump">
<?php
$link_protocol = USE_SSL ? 'https' : NULL;
?>
<p>
Can't access your account?
</p>
</div>
<div class="form-group form-padding">
<button type="submit" class="btn btn-success btn-full">Sign In</button>
</div>
<?php echo form_close(); ?>
Just add the Controller uri in:
$config['csrf_exclude_uris'] = array();
//e.g. $config['csrf_exclude_uris'] = array('register/add_member');
Where register is your controller and add_member is the method.
I am having trouble to post a html form. I am posting one form and getting the post value to my variable and then I am post this form but this form is not posting.
HTML code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" autocomplete="off">
<div class="widget-box">
<div class="widget-title"> <span class="icon"> <i class="icon-user"></i> </span>
<h5>Amc details</h5>
</div>
<div class="widget-content">
<div class="controls controls-row">
<div class="control-group span3">
<label for="normal" class="control-label">Installation Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-ins-date" data-date="01-02-2016" name="amc-ins-date" data-date-format="dd-mm-yyyy" class="datepicker span12" placeholder="Enter installation date">
</div>
</div>
<div class="control-group span3">
<label for="normal" class="control-label">Start Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-start-date" data-date="01-02-2016" name="amc-start-date" data-date-format="dd-mm-yyyy" placeholder="Enter amc start date" class="datepicker span12 ins-date">
</div>
</div>
<div class="control-group span3">
<label class="control-label">End Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-end-date" data-date="01-02-2016" name="amc-end-date" data-date-format="dd-mm-yyyy" placeholder="Enter amc end date" class="datepicker span12 ins-date">
</div>
</div>
<div class="control-group span3">
<label class="control-label">Amount<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-amount" name="amc-amount" class="span12" placeholder="Enter amc amount">
</div>
</div>
</div>
</div>
<div class="form-actions">
<input style="float:right" type="submit" name="amc-installation" class="btn btn-success" value="Save">
</div>
</form>
PHP code:
// i have submitted a form here and its posted
// installation details
$mc_serial = $_POST['mc-serial'];
$mc_model = $_POST['mc-model'];
$contract_type = $_POST['contract_type'];
$no_of_copies = $_POST['no-of-copies'];
$spare_part = join(",",$_POST['spare-part']);
$eng_name = $_POST['eng-name'];
$review = $_POST['review'];
// check if the machine already exits
if(IsMachine($mc_serial,$con)){
echo msgIsMachine();
exit();
}
if($contract_type == 'AMC'){
require './forms/amc.php'; // this is the html i have shown above
} elseif ($contract_type == 'ASC') {
require './forms/asc.php';
} elseif ($contract_type == '4C') {
require './forms/4c.php';
} elseif ($contract_type == 'RENTAL') {
require './forms/rental.php';
} elseif ($contract_type == 'WARRANTY') {
require './forms/warranty.php';
}
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);($_POST);
}
The output of var_dump is NULL. I don't get any problem.
You echo the second form (during the script which responds to the submission of the first one), but then immediately check for values returned from it within the same script execution. You have to wait for the user to post the form back before you can check the submitted values. This would be a separate postback, and therefore a separate execution context for the PHP.
So the code to check the values from the second form needs to be in a separate section (or file) which is triggered by the submission of the second form.
There's no $POST in PHP you should use $_POST instead :
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);
}
NOTE : You should place the var_dump($_POST); inside the if statement, so it will be trrigered just after the submit.
Hope this helps.
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);
}
You should use $_POST not $POST.
Hope this will helps you :)
After submit in signup page my signUp page redirects to info.php where I want to collect additional info of user using email id he gives on signup page but when I tried to get the email id of user through sessions, session return empty value.
THIS IS MY SIGNUP CODE
<?php
session_start();
if(isset($_POST['submit'])){
$name= $_POST['_user'];
$email = $_POST['_email'];
$pass = $_POST['_password'];
//Insert Data
$sql = "INSERT INTO signup(name,email,password)
VALUES('$name','$email','$pass')";
//Data Validation
if(mysqli_query($conn,$sql)){
echo "<script>alert('SignUp Successfull')</script>";
$_SESSION['user_email'] = $email;
header('Location: info.php');
}
else{
echo "<script>window.alert('You are already a user.')</script>";
}
}
mysqli_close($conn);
?>
AND THIS MY INFO.PHP CODE
<?php
session_start();
if(isset($_POST['_submit'])){
if(empty($_POST['_address']) || empty($_POST['_country']) || empty($_POST['_number']) || empty($_POST['_cnic']) || empty($_POST['_passport'])){
echo "<script>window.alert('All fields are required')</script>";
}
else{
$address = $_POST['_address'];
$country = $_POST['_country'];
$number = $_POST['_number'];
$cnic = $_POST['_cnic'];
$passport = $_POST['_passport'];
$email=$_SESSION['user_email'];
$query = "INSERT INTO info(email,address,country,mobile,cnic,passport)
VALUES('$email','$address','$country','$number','$cnic','$passport')";
if(mysqli_query($conn,$query)){
header('Location: ../index.php');
}
else{
echo "<script>window.alert('Error While Entering the data!.')</script>";
}
}
}
mysqli_close($conn);
?>
In addition I use this global session variable for login page and it works fine.
UPDATE
SIGNUP HTML CODE
<div class="outside">
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<label class="control-label col-sm-3 glyphicon glyphicon-user" for="name"></label>
<div class="control-label col-sm-8">
<input type="text" name="_user" class="form-control" id="name" placeholder="Full Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="email">
<img class="glyphicon1" src="../assests/at-sign.png">
</label>
<div class="control-label col-sm-8">
<input type="email" name="_email" class="form-control" id="email" placeholder="Enter Email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3 glyphicon glyphicon-lock" for="password"></label>
<div class="control-label col-sm-8">
<input type="password" name="_password" class="form-control" id="password" placeholder="Enter Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-3">
<button name="submit" id="submit" value="Upload" type="submit" class="btn btn-default">Confirm SignUp</button>
</div>
</div>
<p>Already a User? LogIn</p>
</form>
</div>
Use this for Returns the auto generated id used in the last query
mysqli_insert_id($link)
I have a dozen fully functional scripts that use heredoc statements to display HTML including e.g. $errors[field_name] yet this nearly identical script results in POST errors like
"Notice: Undefined index: user_password in register.php on line 162"
When the user enters a password with 5 characters when 8+ characters are required, a validation function populates $errors['password'] and the form is supposed to re-display along with validation errors.
Can't see what I'm missing in this Bootstrap style form. The $errors array is global and I can force the display of errors, so I know errors are initialized but I keep getting
"Notice: Undefined index"
$fields = array( 'user_name', 'user_email', 'user_password', 'user_password2' );
function display_form($string = '')
{
global $error_token, $cfg, $fields, $form, $errors, $s, $token, $validation_status;
$error_message = '';
switch($_SERVER['REQUEST_METHOD'])
{
Case 'POST':
// validation failed, redisplay the form
$autofocus = '';
foreach($fields as $field){
$$field = htmlentities(get_cgi_var($field), ENT_QUOTES, 'UTF-8');
// wrap errors in Bootstrap alert markup
$errors[$field] = !empty($errors[$field]) ? '<div class="alert alert-danger">'.htmlentities($errors[$field], ENT_QUOTES, 'UTF-8').'</div>' : '';
// debug, force the premature display of errors.
// echo !empty($errors[$field]) ? '<div class="alert alert-danger">'.htmlentities($errors[$field], ENT_QUOTES, 'UTF-8').'</div>' : '<p>empty</p>';
}
break;
Case 'GET':
default:
$autofocus = 'autofocus';
foreach($fields as $field){
$$field = '';
$errors[$field] = '';
}
$error_token = '';
break;
};
foreach($fields as $field){
$validation_status[$field] = empty($errors[$field]) ? ' has-success' : ' has-error';
}
$self = SELF;
print<<<_HTML_
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading">Registration</div>
<div class="panel-body">
$string
$error_message
<form name="form1" id="form1" action="$self" class="form-horizontal" role="form" method="POST">
<fieldset>
$error_token
$errors[user_name]
<div class="row form-group$validation_status[user_name]">
<label for="user_name" class="col-lg-3 control-label">Name</label>
<div class="col-lg-9">
<input type="text" name="user_name" id="user_name" value="$user_name" maxlength="255" $autofocus required placeholder="Your First & Last Name" title="Your First & Last Name" autocomplete="on" class="form-control">
</div>
</div>
$errors[user_email]
<div class="row form-group$validation_status[user_email]">
<label for="user_email" class="col-lg-3 control-label">Email</label>
<div class="col-lg-9">
<input type="email" name="user_email" id="user_email" value="$user_email" maxlength="255" required placeholder="Your Email Address" autocomplete="on" class="form-control">
</div>
</div>
$errors[user_password]
<div class="row form-group$validation_status[user_password]">
<label for="user_password" class="col-lg-3 control-label">Password</label>
<div class="col-lg-9">
<input type="text" name="user_password" id="user_password" value="$user_password" maxlength="255" required placeholder="Password or Passphrase" autocomplete="on" class="form-control">
<p class="help-block">Case sensitive password containing 8+ characters or a phrase containing 3-5 words</p>
</div>
</div>
$errors[user_password2]
<div class="row form-group$validation_status[user_password2]">
<label for="user_password2" class="col-lg-3 control-label">Password</label>
<div class="col-lg-9">
<input type="text" name="user_password2" id="user_password2" value="$user_password2" maxlength="255" required placeholder="Re-enter Password or Passphrase" autocomplete="on" class="form-control">
</div>
</div>
<div class="row form-group">
<label for="submit_button" class="col-lg-3 control-label"> </label>
<div class="col-lg-9 text-center">
<input type="hidden" name="token" value="$token">
<input type="submit" name="submit_button" id="submit_button" value="Submit" onClick="return captcha_validation(this.form);" class="btn btn-primary">
</div>
</div>
</fieldset>
</form>
</div><!-- /panel-body -->
<div class="panel-footer text-center"> </div>
</div><!-- /panel -->
</div><!-- /col -->
<div class="col-lg-6">
<div class="well">unused column</div>
</div><!-- /col -->
_HTML_;
};
Here's your problem:
default:
$autofocus = 'autofocus';
foreach($fields as $field){
$$field = ''; // <------------------
$errors[$field] = '';
}
$error_token = '';
break;
replace $$field with $field or remove it altogether - it's not needed here.