I have two form in one page. When I click on the submit button of form one, the validation error shows on both forms. How could show separate validation errors on each form?
This is my view:
<?php echo form_open('user_signup/login',['class'=>'login-form','id'=>'submit_form']);
echo validation_errors();?>
<h3 class="form-title font-green">Sign In</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span> Enter any username and password. </span>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">Email</label>
<?php echo form_input(['name'=>'email1','type'=>'text','style'=>'text-transform: capitalize;','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Email','value'=>set_value('email1')]); ?>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<?php echo form_input(['name'=>'pass','type'=>'password','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Password']); ?>
</div>
<div class="form-actions">
<?php echo form_submit('submit', 'Submit',"class='btn green uppercase'" ); ?>
Forgot Password?
</div>
<div class="login-options">
<h4>Or login with</h4>
<ul class="social-icons">
<li>
<a class="social-icon-color facebook" data-original-title="facebook" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color twitter" data-original-title="Twitter" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color googleplus" data-original-title="Goole Plus" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color linkedin" data-original-title="Linkedin" href="javascript:;"></a>
</li>
</ul>
</div>
<div class="create-account">
<p>
Create an account
</p>
</div>
</form>
<!-- END LOGIN FORM -->
<!-- BEGIN FORGOT PASSWORD FORM -->
<form class="forget-form" action="http://keenthemes.com/preview/metronic/theme/admin_2/index.html" method="post">
<h3 class="font-green">Forget Password ?</h3>
<p> Enter your e-mail address below to reset your password. </p>
<div class="form-group">
<input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="Email" name="email" /> </div>
<div class="form-actions">
<button type="button" id="back-btn" class="btn green btn-outline">Back</button>
<button type="submit" class="btn btn-success uppercase pull-right">Submit</button>
</div>
</form>
<!-- END FORGOT PASSWORD FORM -->
<!-- BEGIN REGISTRATION FORM -->
<?php echo form_open('user_signup/login',['class'=>'register-form','id'=>'register_form']);
?>
<h3 class="font-green">Sign Up</h3>
<p class="hint"> Enter your personal details below: </p>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Roll NO</label>
<?php echo form_input(['name'=>'rollno','type'=>'text','style'=>'text-transform: capitalize;','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Rollno','value'=>set_value('rollno')]); ?>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">Email</label>
<?php echo form_input(['name'=>'email2','type'=>'text','style'=>'text-transform: capitalize;','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Email','value'=>set_value('email2')]); ?>
</div>
<div class="form-actions">
<button type="button" id="register-back-btn" class="btn green btn-outline">Back</button>
<?php echo form_submit('register', 'register',"class='btn btn-success uppercase pull-right'" ); ?>
This is my controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User_signup extends CI_Controller {
public function index()
{
$this->load->view('User/signup');
}
public function login()
{
if ($this->input->post('submit_form')) {
$rules['email1'] = 'required';
$rules['pass'] = 'required';
$this->form_validation->set_rules($rules);
}
else if ($this->input->post('register_form')) {
$rules['rollno'] = 'required';
$rules['email2'] = 'required';
$this->validation->set_rules($rules);
}
if (!$this->form_validation->run()) {
$this->load->view('User/signup');
}
else {
if ($this->input->post('submit_form'))
echo 'Form 1 posted !';
else if ($this->input->post('register_form'))
echo 'Form 2 posted !';
}
}
}
There are two things you need to concern about that. First passing action in HTML form. Second is, getting those parameters and code accordingly in your controller's action.
<?php echo form_open('user_signup/login/form-1',['class'=>'login-form','id'=>'submit_form']);
echo validation_errors();?>
<h3 class="form-title font-green">Sign In</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span> Enter any username and password. </span>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">Email</label>
<?php echo form_input(['name'=>'email1','type'=>'text','style'=>'text-transform: capitalize;','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Email','value'=>set_value('email1')]); ?>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<?php echo form_input(['name'=>'pass','type'=>'password','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Password']); ?>
</div>
<div class="form-actions">
<?php echo form_submit('submit', 'Submit',"class='btn green uppercase'" ); ?>
Forgot Password?
</div>
<div class="login-options">
<h4>Or login with</h4>
<ul class="social-icons">
<li>
<a class="social-icon-color facebook" data-original-title="facebook" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color twitter" data-original-title="Twitter" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color googleplus" data-original-title="Goole Plus" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color linkedin" data-original-title="Linkedin" href="javascript:;"></a>
</li>
</ul>
</div>
<div class="create-account">
<p>
Create an account
</p>
</div>
</form>
<!-- END LOGIN FORM -->
<!-- BEGIN FORGOT PASSWORD FORM -->
<form class="forget-form" action="http://keenthemes.com/preview/metronic/theme/admin_2/index.html" method="post">
<h3 class="font-green">Forget Password ?</h3>
<p> Enter your e-mail address below to reset your password. </p>
<div class="form-group">
<input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="Email" name="email" /> </div>
<div class="form-actions">
<button type="button" id="back-btn" class="btn green btn-outline">Back</button>
<button type="submit" class="btn btn-success uppercase pull-right">Submit</button>
</div>
</form>
<!-- END FORGOT PASSWORD FORM -->
<!-- BEGIN REGISTRATION FORM -->
<?php echo form_open('user_signup/login/form-2',['class'=>'register-form','id'=>'register_form']);
?>
<h3 class="font-green">Sign Up</h3>
<p class="hint"> Enter your personal details below: </p>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Roll NO</label>
<?php echo form_input(['name'=>'rollno','type'=>'text','style'=>'text-transform: capitalize;','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Rollno','value'=>set_value('rollno')]); ?>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">Email</label>
<?php echo form_input(['name'=>'email2','type'=>'text','style'=>'text-transform: capitalize;','class'=>'form-control form-control-solid placeholder-no-fix','autocomplete'=>'off','placeholder'=>'Email','value'=>set_value('email2')]); ?>
</div>
<div class="form-actions">
<button type="button" id="register-back-btn" class="btn green btn-outline">Back</button>
<?php echo form_submit('register', 'register',"class='btn btn-success uppercase pull-right'" ); ?>
Note: Check form actions
Here is your updated controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User_signup extends CI_Controller {
public function index()
{
$this->load->view('User/signup');
}
public function login()
{
// Checking passed 3rd parameter in URI string.
$submitted_form = $this->uri->segment(3)?$this->uri->segment(3):false;
if ($submitted_form == 'form-1') {
$rules['email1'] = 'required';
$rules['pass'] = 'required';
$this->form_validation->set_rules($rules);
}
if ($submitted_form == 'form-2') {
$rules['rollno'] = 'required';
$rules['email2'] = 'required';
$this->validation->set_rules($rules);
}
if ($this->form_validation->run()) {
if ($submitted_form == 'form-1')
echo 'Form 1 posted !';
else if ($submitted_form == 'form-1')
echo 'Form 2 posted !';
}
$this->load->view('User/signup');
}
}
Let me know if you have any confusion.
Submit by Jquery. For Example in your view
<form id="form1" action="" method="post">
<label>Username</label>
<input type="text" name="username">
<label>Password</label>
<input type="password" name="password">
<input type="hidden" name="form_type" value="login">
<button type="submit" onClick="login()">Login</button>
</form>
<form id="form2" action="" method="post">
<label>Username</label>
<input type="text" name="username">
<label>Password</label>
<input type="password" name="password">
<label>Email</label>
<input type="email" name="email">
<input type="hidden" name="form_type" value="register">
<button type="submit" onClick="register()">Login</button>
</form>
Jquery Script
<script>
function login()
{
$('#form1').submit();
}
function register()
{
$('#form2').submit();
}
</script>
Now in your controller
if($_POST)
{
if($_POST['form_type']=='login')
{
// Validate Login
}
elseif($_POST['form_type']=='register')
{
// validate register
}
}
Related
I am writing a php file, where I want to display a different content within an existing html element when a get variable is set.
Now what i want is to set the word " Password Reset Was Success" instead of "Enter your Email to reset the password" or add a new <p> tag containing the required words by hiding current <p> tag when the GET variable is set. But I have no idea of how to do this. I checked different times, but I failed. I really appreciate if some one can help me to do this.
here is my code.
<div class="login-box-body">
<!--Want to replace this text as Password Reset Was Success or add a new <p> tag containing the required words by hiding current <p> tag -->
<p class="login-box-msg">Enter your Email to reset the password</p>
<?php require '_inc/msg.php' ?>
<!-- Check if GET variable is set or not -->
<?php if (isset($_GET['code'])) {
echo '<style>.formPsw{ display:none;}</style>';
} ?>
<form action="" method="post" class="formPsw">
<div class="form-group has-feedback emailBox" >
<input type="email" name="email" class="form-control" placeholder="Email" data-validation="email required">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
</div>
<!-- /.col -->
<div class="col-xs-4 sendEmailBtn">
<input type="submit" name="send" class="btn btn-primary btn-block btn-flat" value="send"/>
</div>
<!-- /.col -->
</div>
</form>
<?php if (!empty($_POST['send'])) {
echo 'Please check your email ('.$_POST['email'].'). We send password reset link to your email.';
} ?>
</div>
You just need to wrap inside if condition:
<div class="login-box-body">
<?php if(isset($_GET['the_get_var_you_are_expecting'])){ ?>
<p class="success">Password Reset Was Success</p>
<?php } else { ?>
<!--Want to replace this text as Password Reset Was Success or add a new <p> tag containing the required words by hiding current <p> tag -->
<p class="login-box-msg">Enter your Email to reset the password</p>
<?php require '_inc/msg.php' ?>
<!-- Check if GET variable is set or not -->
<?php if (isset($_GET['code'])) {
echo '<style>.formPsw{ display:none;}</style>';
} ?>
<form action="" method="post" class="formPsw">
<div class="form-group has-feedback emailBox" >
<input type="email" name="email" class="form-control" placeholder="Email" data-validation="email required">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
</div>
<!-- /.col -->
<div class="col-xs-4 sendEmailBtn">
<input type="submit" name="send" class="btn btn-primary btn-block btn-flat" value="send"/>
</div>
<!-- /.col -->
</div>
</form>
<?php if (!empty($_POST['send'])) {
echo 'Please check your email ('.$_POST['email'].'). We send password reset link to your email.';
} ?>
<?php } ?>
</div>
Im using the COMMMENT FORM in WORDPRESS but I wanna customize the form.The form is wraped by default:
<div id="respond" class="comment-respond">
...
</div>
Now I want to add some class attributes to tag.So can I use filter hook to make that or anyone have good idea for this problem.Thanks
This is code of file comments.php:
<div class="wilpost-component__module mb-30">
<?php if (have_comments() == false) { ?>
<h3 class="postComponent-title">No comment</h3>
<?php } else { ?>
<h3 class="postComponent-title"><?php echo esc_html("(" . get_comments_number() . ")comment"); ?></h3>
<div class="wilpost-comment__module">
<ol class="commentlist">
<?php
wp_list_comments(array('callback' => 'fractal_comment', "style" => "ol"));
?>
</ol>
</div>
<?php } ?>
</div>
<?php comment_form();?>
And this is code I wanna customize my comment form like this:
<div class="wilform__module wilform__feedback">
<form name="wil-feedback" id="wil-feedback" action="#">
<div class="item-group">
<label for="name">name</label>
<input type="text" id="name"/>
<div class="form-icon"><i class="fa fa-user"></i></div>
</div>
<div class="item-group">
<label for="email">email</label>
<input type="email" id="email"/>
<div class="form-icon"><i class="fa fa-envelope"></i></div>
</div>
<div class="item-group">
<label for="textarea">textarea</label>
<textarea></textarea>
</div>
<button class="wil-btn wil-btn--primary wil-btn--md wil-btn--round " type="submit">Subscrible<i class="la la-paper-plane"></i>
</button>
</form>
</div>
I am trying to send multiple files in one request using DropZone js.
<script type="text/javascript">
Dropzone.autoDiscover = false;
var file= new Dropzone(".dropzone",{
url: any url,
method:"post",
paramName:"PhotoFiles",
addRemoveLinks:true,
autoProcessQueue: false
});
//Upload file onsubmit
$('#UploadMultiFiles').submit(function(){
file.processQueue();
});
file.on("sending",function(a,b,c){
a.token=Math.random();
c.append("token",a.token);
});
The issue is I have other inputs in the same form that is why I used onsubmit, and these inputs are saved in a table and the images from dropzone are saved in another table with and both tables have one to many relationship
The Controller like:
public function university_offers($id){
$data['university_offer_name']=$this->input->post('university_offer_name');
$data['university_id_fk']=$this->input->post('university_id_fk');
$data['university_offer_details']=$this->input->post('university_offer_details');
if ($this->input->post('save')){
$data2['university_offer_id_fk'] = insertrecords('university_offers',$data);
$data2['university_id_fk'] = $data['university_id_fk'];
//when I put the next IF at the begining of the function it works but ofcourse without the other data fields that I need.
if(isset($_FILES) && $_FILES != null){
$data2['photo_name'] = upload_image('PhotoFiles');
insertrecords('university_offer_photos',$data2);
}
if (insertrecords('university_offer_photos',$data2)==true)
message('success','');
redirect('Admin/university_offers/0','refresh');
}
$data['view']="admin/universities/university_offers";
$this->load->view('index',$data);
}
What I need is sending al uploaded files and do a loop in the controller to save it right in the database, not sending each file to the controller and saving it.
Edit:
My view is like:
<form action="university_offers/<?=$id?>" id="UploadMultiFiles" autocomplete="off" method="post" enctype="multipart/form-data" class="m-t-5" novalidate>
<div class="form-body">
<h3 class="card-title">بيانات العرض</h3>
<hr>
<div class="row p-t-20">
<div class="col-md-6">
<div class="form-group">
<label class="control-label">إسم العرض<span class="text-danger">*</span></label>
<div class="controls">
<input type="text" autocomplete="off" name="university_offer_name" class="form-control" required value="<?php if(isset($result)) echo $result['university_offer_name']?>" data-validation-required-message="يجب إدخال إسم العرض" placeholder="إسم العرض">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">إسم الجامعة<span class="text-danger">*</span></label>
<div class="controls">
<select name="university_id_fk" id="select" class="form-control" required data-validation-required-message="يجب إختيار الجامعة" aria-invalid="false">
<option value="">إختر الجامعة</option>
<?php
foreach (selectrecords("*",'universities') as $university):
$select = '';
if(isset($result) && $result['university_id_fk'] == $university->university_id_pk)
$select = 'selected';
?>
<option <?=$select?> value="<?php echo $university->university_id_pk ?>"><?php echo $university->university_name ?></option>
<?php endforeach;?>
</select>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="control-label">تفاصيل العرض<span class="text-danger">*</span></label>
<div class="controls">
<textarea id="mymce" name="university_offer_details"><?php if(isset($result)) echo $result['university_offer_details'] ?></textarea>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="control-label">صور العرض<span class="text-danger">*</span></label>
<div class="row">
<?php
if(isset($result)) {
foreach (selectrecords('*','university_offer_photos',array('university_offer_id_fk'=>$result['university_offer_id_pk'])) as $photo):
echo'
<div class="form-group text-center" id="'.$photo->photo_id_pk.'">
<div class="col-md-12">
<img style="border: none; height: 150px; width: 150px; border-radius: 10px;" class="img-thumbnail" src="'.base_url().'public/uploads/images/'.$photo->photo_name.'">
</div>
حذف الملف
</div>
';
endforeach;
}
?>
</div>
<div class="dropzone">
<div class="dz-message">
<span> Drag and Drop your files here Or Click here to upload</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-actions">
<input type="hidden" id="url" value="university_offers/<?=$id?>" />
<?php
if($id == 0)
echo '<button type="submit" id="butt" name="save" value="save" class="btn btn-primary"> <i class="fa fa-check"></i> حفظ</button>';
else
echo '<button type="submit" id="butt" name="edit" value="edit" class="btn btn-primary"><i class="fa fa-check"></i> حفظ</button>';
?>
<button type="reset" class="btn btn-inverse"><i class="fa fa-times"></i> إلغاء</button>
<?php
if($id == 0)
echo'<button type="button" id="backword" class="btn btn-second"><i class="fa fa-undo"></i> رجوع</button>';
else{
echo '<input type="hidden" name="university_offer_id_pk" value="'.$result['university_offer_id_pk'].'"/>
<button type="button" class="btn btn-second"><i class="fa fa-undo"></i> رجوع</button>';
}
?>
</div>
</div>
</form>
upload_image function, I put it in the Helper
function upload_image($file_name){
$CI =& get_instance();
$config['upload_path'] = 'public/uploads/images';
$config['allowed_types'] = 'gif|Gif|ico|ICO|jpg|JPG|jpeg|JPEG|BNG|png|PNG|bmp|BMP|WMV|wmv|MP3|mp3|FLV|flv|SWF|swf';
$config['max_size'] = '1024*8';
$config['encrypt_name']=true;
$CI->load->library('upload',$config);
if(! $CI->upload->do_upload($file_name)){
return false;
}else{
$datafile = $CI->upload->data();
thumb($datafile);
watermark($datafile);
return $datafile['file_name'];
}}
I have a form page with a authController for validation.
Here is the code of the form page:
<div class="main-content">
<h3>log in as student</h3>
<h3>
<!-- SHOW URL MESSAGE HERE -->
</h3>
<form action="../app/controllers/authController.php" class="login_form" method="POST">
<div class="form-group">
<label for="username">Username</label>
<input type="text" name="username" id="" class="input_field">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="" class="input_field">
</div>
<div class="form-group">
<input type="submit" name="type" id="" value="Log In" class="btn btn-info">
</div>
</form>
</div>
And here is the code form the authController:
if ($_POST['type'] == 'Log In') {
if (! Validator::notEmpty()->validate($_POST['username']) ||
! Validator::notEmpty()->validate($_POST['password'])) {
$err_msg = "One of the fields is empty";
$user->redirect('stu_login.php?type=' . $err_msg);
exit;
}
How do i show the $err_msg that is defined in the authController, on the form page where the <!-- SHOW URL MESSAGE HERE --> is?
Replace
$user->redirect('stu_login.php?type=' . $err_msg);
To
$user->redirect('stu_login.php?msg=' . $err_msg);
And use in stu_login.php like this
<h3>
<!-- ERROR OR OTHER MESSAGE -->
<?php
if(isset($_GET['msg'] != '')
echo $_GET['msg'];
?>
</h3>
I tried to make a login page on WHMCS with PHP. My code is like:
<div class="clearfix"></div>
<div class="header_medium two">
<div class="container">
<h3 class="bigtext"> We are <span>Foxuhost.</span></h3>
<h3 class="smalltext"><span>Get 7+</span> Unique Layouts</h3>
</div>
</div>
<!--end header medium-->
<div class="section_holder18">
<div class="container">
<div class="pagetitle">
<h3>Login form</h3>
</div>
<div class="pagenation"> Home <i>/</i> Pages <i>/</i> Login form</div>
</div>
</div>
<!--end pagenation-->
<div class="clearfix"></div>
<div class="section_holder27" name="l1">
<div class="container" name="l2">
<div class="login_form" name="l3">
<form method="post" id="sky-form" class="sky-form" name="l4">
<header>Login form</header>
<fieldset name="l5">
<section name="l6">
<div class="row" name="l7">
<label class="label col col-4">E-mail</label>
<div class="col col-8"name="l8">
<label class="input" name="l9">
<i class="icon-append icon-user"></i>
<input type="email" name="emailer">
</label>
</div>
</div>
</section>
<section>
<div class="row">
<label class="label col col-4">Password</label>
<div class="col col-8">
<label class="input">
<i class="icon-append icon-lock"></i>
<input type="password" name="password6">
</label>
<div class="note">Forgot password?</div>
</div>
</div>
</section>
<section>
<div class="row">
<div class="col col-4"></div>
<div class="col col-8">
<label class="checkbox"><input type="checkbox" name="remember" checked><i></i>Keep me logged in</label>
</div>
</div>
</section>
</fieldset>
<footer>
<div class="fright">
Register
<button type="submit" name="send" value="send" class="button eight">Log in</button>
</div>
</footer>
</form>
</div>
<form action="http://trixia.dk/templates/d/demo-recovery.php" id="sky-form2" class="sky-form sky-form-modal">
<header>Password recovery</header>
<fieldset>
<section>
<label class="label">E-mail</label>
<label class="input">
<i class="icon-append icon-user"></i>
<input type="email" name="email" id="email">
</label>
</section>
</fieldset>
<footer>
<button type="submit" name="submit" class="button">Submit</button>
Close
</footer>
<div class="message">
<i class="icon-ok"></i>
<p>Your request successfully sent!<br>Close window</p>
</div>
</form>
{if $_post["emailer"] != ""}
<div class="error-box alert"> <span><i class="fa fa-exclamation-triangle"></i> Error – message will goes here</span> <a class="mboxes_close" href="#"><i class="fa fa-times"></i></a> </div><!--end item-->
{else}
<h1>asdasd</h1>
{/if}
</div>
</div>
<!--end section 22-->
{literal}
<script type="text/javascript">
function validerform125() {
var email = document.getElementsByName("password6")[0].value;
var password = document.getElementsByName("emailer")[0].value;
if (email == "" && password == "") {
alert("Du skal udfylde alle felter");
}
else if (email == "") {
alert("Du har ikke skrevet noget email");
return false;
}else if (password == "") {
alert("Du har ikke skrevet noget password");
return false;
}else if(email != $values["email"]) {
alert("Dit brugernavn er ikke rigtigt");
return false;
}else if() {
}
else{
alert("Der skete noget");
return false;
}
}
</script>
{/literal}
the if statements is a bit over <!--end section 22-->
I tried it on a smaller website and it works fine.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form method="post">
<div>
Navn <input name="navn" type="text"><br/>
Email <input name="email" type="email"><br/>
</div>
<div>
<input type="submit" name="send" value="send">
</div>
</form>
<?php
if ($_POST["navn"] == "") {
echo "hejsa";
return;
}else{
echo "hejsa2";
}
?>
</body>
</html>
The error is that when i press the login button it doesn't do the if statement. But it prints out the "else" statement, when i load the website.
Is the first file you provided a smarty .tpl file? If so, you will need to change the bottom section to something like this:
...
</div>
</form>
{php}if ( $_POST["emailer"] != "" ) :{/php}
<div class="error-box alert"> <span><i class="fa fa-exclamation-triangle"></i> Error – message will goes here</span> <a class="mboxes_close" href="#"><i class="fa fa-times"></i></a> </div><!--end item-->
{php}else:{/php}
<h1>asdasd</h1>
{php}endif;{/php}
</div>
</div>
...
Smarty doesn't know you need to execute PHP unless you tell it. This is also assuming you are not running version 6 of WHMCS with the new execute PHP option disabled in the settings (v6 is still beta as of May 2015 however).
Hope that helps.