我的功能不是读取我的动态文本框值

时间:2016-08-12 11:21:49

标签: php textbox

我很难弄清楚为什么我的功能没有插入我的动态文本框值而其他人正常工作。我只是显示我的动态文本框的代码。

这是我的register.php - 我认为这很好,因为我可以添加和删除文本框。然后,如果我按下提交,它会执行我的doRegister功能。

require_once './library/config.php';
require_once './library/functions.php';

if (isset($_POST['firstname']) && isset($_POST['lastname'])) {
$result = doRegister();
if ($result != '') {
    $errorMessage = $result;
   }
}
?>

这是我的functions.php

function doRegister()
{
$fname  = $_POST['firstname'];
$mname  = $_POST['middlename'];
$lname  = $_POST['lastname'];
$email  = $_POST['email'];  
$phone  = $_POST['phone'];
$cphone = $_POST['cphone'];
$dob    = $_POST['dob'];
$gender = $_POST['gender'];

$add    = $_POST['address'];
$city   = $_POST['city'];
$state  = $_POST['state'];
$zip    = (int)$_POST['zipcode'];
$typeres    = $_POST['type_res'];   
$liveyear   = $_POST['live_year'];

$pwd    = $_POST['password'];

$type   = $_POST['acctype'];
$pin    = (int)$_POST['pin'];

$errorMessage = '';


$sql = "SELECT fname FROM tbl_users WHERE fname = '$fname' and lname = '$lname'";
$result = dbQuery($sql);
if (dbNumRows($result) == 1) {
    $errorMessage = 'Username is already exist, please try another name.';
    return $errorMessage;
}


$accno = rand(9999999999, 99999999999);
$accno = strlen($accno) != 10 ? substr($accno, 0, 10) : $accno;


$images = uploadProductImage('pic', SRV_ROOT . 'images/thumbnails/');
$thumbnail = $images['thumbnail'];
$insert_id = 0; 
$sql = "INSERT INTO tbl_users (fname, lname, pwd, email, phone, gender, is_active, utype, pics, bdate, mname, cpnum, years_in_city, civil_stat, religion, educ_attain, emp_stat, voter, mother_name, mother_maiden, mother_occu, father_name, father_maiden, father_occu, no_sibling, fam_income, type_res)
        VALUES ('$fname', '$lname', PASSWORD('$pwd'), '$email', '$phone', '$gender', 'FALSE', 'USER', '$thumbnail', NOW(), '$mname', '$cphone', '$liveyear', '$cstat', '$religion', '$high_edu', '$emp_stat', '$voter', '$moname', '$momaid', '$mooccu', '$faname', '$famaid', '$faoccu', '$nosib', '$aveincome', '$typeres')"; 
dbQuery($sql);
$insert_id = dbInsertId();

现在这是我插入动态文本框值的代码。

$itemcount = count($_POST["item_name"]);
$itemvalues = 0;

$query = "INSERT INTO item (item_name,item_price) VALUES ";
$queryValue = "";
for($i=0;$i<$itemCount;$i++) {
  if(!empty($_POST["item_name"][$i]) || !empty($_POST["item_price"][$i])) {
     $itemValues++;
 if($queryValue!="") $queryValue .= ",";
 $queryValue .= "('" . $_POST["item_name"][$i] . "', '" .      $_POST["item_price"][$i] . "')";
  }
  }
  $sql = $query.$queryValue;
  if($itemValues!=0) {
  dbQuery($sql);
  }

  header('Location: aregister.php');
  exit;

  }

任何帮助评论建议将不胜感激!非常感谢stackoverflow社区!

0 个答案:

没有答案