我使用 jotform.com 制作了一个表单,并没有进行任何调整,只是将 action="" 更改为我的 .php 文件以进行 $_POST 查询。我有相同的文件打印 $_POST 数组以验证所有值都是从 html 接收的,因此我不会包含 html 代码。我在下面包含了 .php ,在提交表单后 .php 打印以下数组,确认所有内容都已发布:
successArray ( [formID] => 32750985631157 [q1_referral] => John Doe [q12_contactType] => Array ( [0] => Array ( [0] => Prospect ) ) [q3_companyNameindividual] => John Doe\'s Company [q4_dba] => John Doe\'s D.B.A [q15_mainofficePhone] => Array ( [area] => 305 [phone] => 8654565 ) [q28_mainContact] => Array ( [first] => John [last] => Doe ) [q8_address] => Array ( [addr_line1] => 1223 Cedar Ave [addr_line2] => N/A [city] => Miami [state] => Florida [postal] => 33054 [country] => United States ) [q32_email32] => johndoe@email.com [q11_website11] => johndoe@johndoe.com [q29_secondaryContact] => Array ( [first] => [last] => ) [q10_mainofficePhone10] => Array ( [area] => [phone] => ) [q13_mobilePhone13] => Array ( [area] => [phone] => ) [q14_fax14] => Array ( [area] => [phone] => ) [q20_homePhone20] => Array ( [area] => [phone] => ) [q26_otherPhone] => Array ( [area] => [phone] => ) [q30_email2] => [q31_email3] => [q27_secondaryAddress] => Array ( [addr_line1] => [addr_line2] => [city] => [state] => [postal] => [country] => ) [q23_notes] => [website] => [simple_spc] => 32750985631157-32750985631157 )
mysql 表中的所有列都设置为 varchar,当然除了 id 限制为 255。未显示在 mysql 表上的值是:
main_contact varchar(255)
main_phone varchar(255)
main_address varchar(255)
Main_address2 varchar(255)
main_city varchar(255)
main_state varchar(255)
main_postcode varchar(255)
main_country varchar(255)
几个小时以来,我一直在努力确保我正确编写了 php。如果没有人有解决方案,我将发布其他代码。先感谢您。
<?php
require_once('info.php');
mysqli_query($con,"INSERT INTO contacts(referral,name,dba,main_contact,main_phone,main_address,main_address2,main_city,main_state,main_postcode,main_country,main_email,website_address)VALUES('".$_POST['q1_referral']."','".$_POST['q3_companyNameindividual']."','".$_POST['q4_dba']."','".$_POST['q28_mainContact[first]']."','".$_POST['q15_mainofficePhone[phone]']."','".$_POST['q8_address[addr_line1]']."','".$_POST['q8_address[addr_line2]']."','".$_POST['q8_address[city]']."','".$_POST['q8_address[state]']."','".$_POST['q8_address[postal]']."','".$_POST['q8_address[country]']."','".$_POST['q32_email32']."','".$_POST['q11_website11']."')");
echo "success";
print_r($_POST);
?>