Php表单html集成无法正常工作(Ion Auth寄存器)

时间:2017-06-07 07:48:23

标签: php html5 codeigniter

我想在我的注册页面添加一些不错的bottstrap html和css,但我不知道如何将php嵌入到html输入中并用样式显示它。有没有办法做到这一点?

代码生成下一个视图:

form view

完整的.php文件

注意:它显示两种形式(比较结果),php和html + php。只有php的表单工作正常,问题是给它风格。

<?php defined('BASEPATH') OR exit('No direct script access allowed');?>
<link rel="stylesheet" href="<?= base_url('assets/bootstrap2/bootstrap.min.css'); ?>">
<link rel="stylesheet" href="<?= base_url('assets/bootstrap2/bootstrap.css'); ?>">
<link rel="stylesheet" href="<?= base_url('assets/js2/bootstrap.js'); ?>">
<link rel="stylesheet" href="<?= base_url('assets/js2/bootstrap.min.js'); ?>">
<div class="container">
    <?php
    echo isset($_SESSION['auth_message']) ? $_SESSION['auth_message'] : FALSE;
    ?>
    <h1>Registro usuario</h1>
    <?php
    echo form_open();
    echo form_label('Nombre:','first_name').'<br />';
    echo form_error('first_name');
    echo form_input('first_name',set_value('first_name')).'<br />';
    echo form_label('Apellidos:','last_name').'<br />';
    echo form_error('last_name');
    echo form_input('last_name',set_value('last_name')).'<br />';
   // echo form_label('Username:','username').'<br />';
    //echo form_error('username');
    //echo form_input('username',set_value('username')).'<br />';
    echo form_label('Email:','email').'<br />';
    echo form_error('email');
    echo form_input('email',set_value('email')).'<br />';
    echo form_label('Contraseña:', 'password').'<br />';
    echo form_error('password');
    echo form_password('password').'<br />';
    echo form_label('Confirmar contraseña:', 'confirm_password').'<br />';
    echo form_error('confirm_password');
    echo form_password('confirm_password').'<br /><br />';
    echo form_submit('register','Confirmar');
    echo form_close();
    ?>
</div>
<form class="form-horizontal">
<fieldset>

<!-- Form Name -->
<legend>Registro de usuario</legend>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="textinput">Nombre</label>  
  <div class="col-md-4">
     <!-- <input value="" id="textinput" name="textinput" type="text" placeholder="Ej: José Manuel..." class="form-control input-md" required=""> -->
     <?php $nombre = array(
          'name'        => 'first_name',
          'id'          => 'first_name',
          'type'          => 'text',
          'class'       => 'form-control input-md',
          'placeholder'       => 'Ej: José Manuel...',
        ); ?>


 <?php echo form_input($nombre); ?>
   <!-- <?php echo form_input('first_name',set_value('first_name')); ?> -->
  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="textinput">Apellidos</label>  
  <div class="col-md-4">
    <!--  <input value="" id="textinput" name="textinput" type="text" placeholder="Ej: Palma..." class="form-control input-md" required=""> -->

      <?php $apellidos = array(
          'name'        => 'last_name',
          'id'          => 'last_name',
          'type'          => 'text',
          'class'       => 'form-control input-md',
          'placeholder'       => 'Ej: Palma...',
        ); ?>


 <?php echo form_input($apellidos); ?>

  <!--  <?php echo form_input('last_name',set_value('last_name')); ?> -->
  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="textinput">Email</label>  
  <div class="col-md-4">
   <!--   <input value="" id="textinput" name="textinput" type="text" placeholder="Ej: herba@gmail.com..." class="form-control input-md" required=""> -->

      <?php $email = array(
          'name'        => 'email',
          'id'          => 'email',
          'type'          => 'text',
          'class'       => 'form-control input-md',
          'placeholder'       => 'Ej: herba@gmail.com...',
        ); ?>


 <?php echo form_input($email); ?>

  <!--  <?php echo form_input('email',set_value('email'));?> -->
  </div>
</div>

<!-- Password input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="passwordinput">Contraseña</label>
  <div class="col-md-4">
  <!--  <input value="" id="passwordinput" name="passwordinput" type="password" placeholder="Ej: herbaricemills9..." class="form-control input-md" required=""> -->

    <?php $password = array(
          'name'        => 'password',
          'id'          => 'password',
          'type'          => 'password',
          'class'       => 'form-control input-md',
          'placeholder'       => 'Ej: herbaricemills9...',
        ); ?>


 <?php echo form_input($password); ?>

    <!--  <?php echo form_password('password'); ?> -->
  </div>
</div>

<!-- Password input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="passwordinput">Confirmar contraseña</label>
  <div class="col-md-4">
   <!--   <input value="" id="passwordinput" name="passwordinput" type="password" placeholder="Repetir contraseña..." class="form-control input-md" required=""> -->

       <?php $password1 = array(
          'name'        => 'confirm_password',
          'id'          => 'confirm_password',
          'type'          => 'password',
          'class'       => 'form-control input-md',
          'placeholder'       => 'Repetir contraseña...',
        ); ?>


 <?php echo form_input($password1); ?>

  <!--  <?php echo form_password('confirm_password');?> -->
  </div>
</div>

<!-- Button -->
<div class="form-group">
  <label class="col-md-4 control-label" for="singlebutton"></label>
  <div class="col-md-4">
    <!--  <button  value="" id="singlebutton" name="singlebutton" class="btn btn-primary">Confirmar</button> -->

    <!--  <?php $confirm = array(
          'name'        => 'singlebutton',
          'id'          => 'singlebutton',
          //'type'          => 'password',
          'class'       => 'btn btn-primary',

        ); ?>


 <?php echo form_input($confirm); ?> -->

   <?php echo form_submit('register','Confirmar');?> 

  </div>
</div>

</fieldset>
</form>

2 个答案:

答案 0 :(得分:0)

用于插入此

<input value="" id="textinput" name="textinput" type="text" placeholder="Ej: herba@gmail.com..." class="form-control input-md" required="">

尝试使用此示例:

$data = array(
          'name'        => 'textinput',
          'id'          => 'textinput',
          'type'          => 'text',
          'class'       => 'form-control input-md',
          'placeholder'       => 'Ej: herba@gmail.com...',
        );

 echo form_input($data);

答案 1 :(得分:0)

你可以使用如下。 例如first_name字段

$data = array(
          'name'        => 'first_name',
          'id'          => 'first_name',
          'type'          => 'text',
          'class'       => 'form-control input-md',
          'placeholder'       => 'Enter First Name',
        );

 echo form_input($data);

也用于其他元素。