我有一组文本框,其中将包含“名字,姓氏,性别,出生日期,地址等”,我想知道如何对它们进行分组,以便将它们全部提交并输入所有信息进入MySQL数据库。
这是我目前的编码:
<div class="form-group">
此处的名字,姓氏,性别,生日,地址等文本框。
<style type="text/css"> .submit { position: fixed; width: 100%; text-align: center; top: 90%; } </style>
<br />
<div class="submit">
<div class="form-group">
<input type="submit" value="Submit" name="submit" >
</div>
更新1
这就是我所说的;
<form class="form" method="post" action="<?php echo BASE_URL . 'personinfo'; ?>">
示例名字
<style type="text/css"> .firstname { position: fixed; width: 100%; left: 11%; top: 36%; } </style>
<div class="firstname"> <input type="text" value="<?php echo isset($_POST['firstname']) ? $_POST['firstname'] : '';?>" name="firstname" style="width: 18%; height: 4mm"; > </div>
此处的姓氏,性别,出生日期,地址等文本框。
<style type="text/css"> .submit { position: fixed; width: 100%; text-align: center; top: 90%; } </style>
<br />
<div class="submit">
<input type="submit" value="Submit" name="submit" >
</div>
</form>
但是不确定它是否正确,因为它仍然没有提交。
更新2
整个视图包含420行,因此我已经删除了不相关的部分。
(1)第2个(受托者)Javascript函数不起作用。如果删除第一个(国家)功能,它将起作用。在这个阶段,这个问题并不重要。 (2)“请说明您期望发生什么和实际发生什么。” A-单击提交按钮时没有任何反应。 -我希望文本框中包含的信息可以传输到MySQL数据库。设置了控制器和模型可以做到这一点,但是视图必须正确。
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo WEBSITE_NAME; ?> - Person Info</title>
<script type="text/javascript" src="../countries.js"></script>
<script type="text/javascript">function make_blank() { document.trustee.trustee.value =""; } </script>
</head>
<body>
<?php echo validation_errors(); ?>
<?php echo form_open_multipart(BASE_URL.'personinfo',array('name'=>'personinfo_form'));?>
<form class="form" method="post" action="<?php echo BASE_URL . 'personinfo'; ?>">
<style type="text/css"> .username { position: fixed; width: 100%; left: 11%; top: 26%; } </style>
<div class="username"> <input type="text" name="username" readonly value="<?php echo $personinfo->user_name; ?>" style="width: 18%; height: 4mm"; /> </div>
<style type="text/css"> .firstname { position: fixed; width: 100%; left: 11%; top: 36%; } </style>
<div class="firstname"> <input type="text" value="<?php echo isset($_POST['firstname']) ? $_POST['firstname'] : '';?>" name="firstname" style="width: 18%; height: 4mm"; > </div>
<style type="text/css"> .lastname { position: fixed; width: 100%; left: 11%; top: 46%; } </style>
<div class="lastname"> <input type="text" value="<?php echo isset($_POST['lastname']) ? $_POST['lastname'] : '';?>" name="lastname" style="width: 18%; height: 4mm"; > </div>
<style type="text/css"> .othernames { position: fixed; width: 100%; left: 11%; top: 56%; } </style>
<div class="othernames"> <input type="text" value="<?php echo isset($_POST['othernames']) ? $_POST['othernames'] : '';?>" name="othernames" style="width: 18%; height: 4mm"; > </div>
<style type="text/css"> .gender { position: fixed; width: 100%; left: 11%; top: 66%; } </style>
<div class="gender"> <select name="gender" style="width: 18.3%; height: 5.75mm"; >
<option value="">Select One</option>
<option <?php echo isset($_POST['gender']) && $_POST['gender']=="Male" ? 'selected="selected"' : ''?> value="Male">Male</option>
<option <?php echo isset($_POST['gender']) && $_POST['gender']=="Female" ? 'selected="selected"' : ''?> value="Female">Female</option>
<option <?php echo isset($_POST['gender']) && $_POST['gender']=="Other" ? 'selected="selected"' : ''?> value="Other">Other</option>
</select> </div>
<style type="text/css"> .num { position: fixed; width: 100%; left: 40.8%; top: 26%; } </style>
<div class="num">
<select name="num" style="width: 4%; height: 5.75mm"; >
<option value="">Day</option>
<?php
for ($i=1; $i<32; $i++)
{
$selected_day = (isset($_POST['num']) && $_POST['num']==$i ? 'selected="selected"' : '' );
echo '<option '.$selected_day.' value="'.$i.'">'.$i.'</option>';
}
?>
</select>
</div>
<style type="text/css"> .month { position: fixed; width: 100%; left: 46.3%; top: 26%; } </style>
<div class="month">
<select name="month" style="width: 6%; height: 5.75mm"; >
<option value="">Month</option>
<?php
$months = array(
'01'=>'January',
'02'=>'February',
'03'=>'March',
'04'=>'April',
'05'=>'May',
'06'=>'June',
'07'=>'July',
'08'=>'August',
'09'=>'September',
'10'=>'October',
'11'=>'November',
'12'=>'December'
);
foreach ($months as $key=>$month)
{
$selected_month = (isset($_POST['month']) && $_POST['month']==$key ? 'selected="selected"' : '' );
echo '<option '.$selected_month.' value="'.$key.'">' . $month . '</option>';
}
?>
</select>
</div>
<style type="text/css"> .year { position: fixed; width: 100%; left: 53.8%; top: 26%; } </style>
<div class="year">
<select name="year" style="width: 5%; height: 5.75mm"; >
<option value="">Year</option>
<?php
$start_year = 1900;
$end_year = date('Year');
$years = range($start_year,$end_year);
$reverse_year = array_reverse($years);
foreach ($reverse_year as $year)
{
$selected_year = (isset($_POST['year']) && $_POST['year']==$year ? 'selected="selected"' : '' );
echo '<option '.$selected_year.' value="'.$year.'">'.$year.'</option>';
}
?>
</select>
</div>
<style type="text/css"> .certificate { position: fixed; width: 18.3%; left: 40.8%; top: 36%; font-family: arial; font-size: 80%; color: Black; background-color: White; } </style>
<div class="certificate"> <input type="file" name="certificate" id="certificate" style="width: 100%; height: 5mm"; > </div>
<style type="text/css"> .passphoto { position: fixed; width: 18.3%; left: 40.8%; top: 46%; font-family: arial; font-size: 80%; color: Black; background-color: White; } </style>
<div class="passphoto"> <input type="file" name="passphoto" id="passphoto" style="width: 100%; height: 5mm"; > </div>
<style type="text/css"> .fingerprints { position: fixed; width: 18.3%; left: 40.8%; top: 56%; font-family: arial; font-size: 80%; color: Black; background-color: White; } </style>
<div class="fingerprints"> <input type="file" name="fingerprints" id="fingerprints" style="width: 100%; height: 5mm"; > </div></form>
<style type="text/css"> .trustee { position: fixed; width: 100%; left: 40.8%; top: 66%; } </style>
<div class="trustee"><input type="text" name="trustee" id="trustee" style="width: 18%; height: 4mm"; value='To Be Advised' onclick="make_blank();"></div>
<style type="text/css"> .countryterritory { position: fixed; width: 100%; left: 70.5%; top: 26%; } </style>
<div class="countryterritory"> <select name="countryterritory" id="countryterritory" onchange="setStates();" style="width: 18.3%; height: 5.75mm"; >
<option hidden="true">Tap+DownUpArrows+Enter</option>
<option <?php echo isset($_POST['countryterritory']) && $_POST['countryterritory']=="Afghanistan" ? 'selected="selected"' : ''?> value="Afghanistan">Afghanistan</option>
<option <?php echo isset($_POST['countryterritory']) && $_POST['countryterritory']=="Albania" ? 'selected="selected"' : ''?> value="Albania">Albania</option>
<option <?php echo isset($_POST['countryterritory']) && $_POST['countryterritory']=="Algeria" ? 'selected="selected"' : ''?> value="Algeria">Algeria</option>
<style type="text/css"> .stateprovinceregion { position: fixed; width: 100%; left: 70.5%; top: 36%; } </style>
<div class="stateprovinceregion"> <select name="stateprovinceregion" id="stateprovinceregion" onchange="setCities();" style="width: 18.3%; height: 5.75mm"; > </select> </div>
<style type="text/css"> .citytowndistrict { position: fixed; width: 100%; left: 70.5%; top: 46%; } </style>
<div class="citytowndistrict"> <select name="citytowndistrict" id="citytowndistrict" style="width: 18.3%; height: 5.75mm"; > </select> </div>
<style type="text/css"> .suburbvillage { position: fixed; width: 100%; left: 70.5%; top: 56%; } </style>
<div class="suburbvillage"> <input type="text" value="<?php echo isset($_POST['suburbvillage']) ? $_POST['suburbvillage'] : '';?>" name="suburbvillage" style="width: 18%; height: 4mm"; > </div>
<style type="text/css"> .streetroadavenue { position: fixed; width: 100%; left: 70.5%; top: 66%; } </style>
<div class="streetroadavenue"> <input type="text" value="<?php echo isset($_POST['streetroadavenue']) ? $_POST['streetroadavenue'] : '';?>" name="streetroadavenue" style="width: 18%; height: 4mm"; > </div>
<style type="text/css"> .submit { position: fixed; width: 100%; text-align: center; top: 90%; } </style>
<br />
<div class="submit">
<input type="submit" value="Submit" name="submit" >
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
我重建了脚本并删除了这一行
<form class="form" method="post" action="<?php echo BASE_URL . 'personinfo'; ?>">
因此中间编码中肯定有一个错误,但是现在可以使用了。
JavaScript更改为;
<script type="text/javascript" src="../countries.js"></script>
<script type="text/javascript"> function make_blank() { document.forms["personinfo_form"]["trustee"].value = ""; } </script>
这两个功能现在都可以使用。