在下面的表格中,我根据资产标题值从mysql数据库加载问题和答案,并向数据库提交动态自定义问题值。 (这很好) 但我的问题是,当表单值被提交到数据库时,如果资产的自定义问题少于15个,我就不会收到消息。
我想我在 createlead.php 文件中做错了,如果条件......
请帮忙。
如果您认为可以通过其他方法解决此问题,请告知我们。
<?php
require_once 'db_config.php';
//if form is submitted
if($_POST) {
$validator = array('success' => false, 'messages' => array());
$assettitle= $_POST['assettitle'];
$customquestion1= $_POST['cq1'];
$customquestion2= $_POST['cq2'];
$customquestion3= $_POST['cq3'];
$customquestion4= $_POST['cq4'];
$customquestion5= $_POST['cq5'];
$customquestion6= $_POST['cq6'];
$customquestion7= $_POST['cq7'];
$customquestion8= $_POST['cq8'];
$customquestion9= $_POST['cq9'];
$customquestion10= $_POST['cq10'];
$customquestion11= $_POST['cq11'];
$customquestion12= $_POST['cq12'];
$customquestion13= $_POST['cq13'];
$customquestion14= $_POST['cq14'];
$customquestion15= $_POST['cq15'];
$sql = "INSERT INTO ltfs (assettitle, customquestion1, customquestion2, customquestion3, customquestion4, customquestion5, customquestion6, customquestion7, customquestion8, customquestion9, customquestion10, customquestion11, customquestion12, customquestion13, customquestion14, customquestion15) VALUES ('$assettitle', '$customquestion1', '$customquestion2', '$customquestion3', '$customquestion4', '$customquestion5', '$customquestion6', '$customquestion7', '$customquestion8', '$customquestion9', '$customquestion10', '$customquestion11', '$customquestion12', '$customquestion13', '$customquestion14', '$customquestion15')";
$query = $connect->query($sql);
if($query === TRUE) {
$validator['success'] = true;
$validator['messages'] = "Your lead successfully submited to quality team";
} else {
$validator['success'] = false;
$validator['messages'] = "Error while adding the lead information";
}
// close the database connection
$connect->close();
echo json_encode($validator);
}
Jquery(将表单字段值发送到php文件): -
name = []
for line in lines: #get each element out of list
name.append(line.loc_name) #get name of the line
value=line.GetAttribute('c:loading')
print('Loading of the line: %s = %.2f%%'%(name,value))
createlead.php(将表单字段值提交到数据库): -
{{1}}
答案 0 :(得分:0)
我认为这里犯了错误
if($query === TRUE)
你可以这样做
if($query){//you message}else{//error message}