在表中插入变量


Insert variables into table

在表中插入这样的变量是真的吗?因为我没有插入任何内容,警报消息也不会显示在上

我在Joomla的文章中使用扩展添加php代码

require_once JPATH_BASE . '/tools/config.php';
include JPATH_BASE . '/tools/subvterms.php';
if(isset($_POST['check'])){

echo " <style> 
.termsContent { display: none;}
.service-content { display: inline; width: 100%}
</style> " ;
}
if (isset($_POST['send'])) {
$firstname = $_POST['firstname'];
$fathername = $_POST['fathername'];
$grandfathername = $_POST['grandfathername'];
$familyname = $_POST['familyname'];
$identity = $_POST['identity'];
$borndate = $_POST['borndate'];
$mobilenumber = $_POST['mobilenumber'];
$cityliving = $_POST['cityliving'];
$livingshare = $_POST['livingshare'];
$parentslive = $_POST['parentslive'];
$livingtype = $_POST['livingtype'];
$owndate = $_POST['owndate'];
$parentscity = $_POST['parentscity'];
$parentsnighborhood = $_POST['parentsnighborhood'];
$nearestmosque = $_POST['nearestmosque'];
$jobname = $_POST['jobname'];
$jobplace = $_POST['jobplace'];
$salary = $_POST['salary'];
$gotsub = $_POST['gotsub'];
$gotmarried = $_POST['gotmarried'];
$wifestatus = $_POST['wifestatus'];
$nekahdate = $_POST['nekahdate'];
$gowithwife = $_POST['gowithwife'];
$marriagedate = $_POST['marriagedate'];
$nomarriagedate = $_POST['nomarriagedate'];
$restofmoney = $_POST['restofmoney'];
$datetime = time();

$con->set_charset('utf8');
$stmt = mysqli_prepare($con,"INSERT INTO subventions (firstname,fathername,grandfathername,familyname,identity,borndate,mobilenumber,cityliving,livingshare,parentslive,livingtype,owndate,parentscity,parentsnighborhood,nearestmosque,jobname,jobplace,salary,gotsub,gotmarried,wifestatus,nekahdate,gowithwife,marriagedate,nomarriagedate,restofmoney,datetime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$bind = mysqli_stmt_bind_param($stmt,"ssssssssssssssssssssssssssi",$firstname,$fathername,$grandfathername,$familyname,$identity,$borndate,$mobilenumber,$cityliving,$livingshare,$parentslive,$livingtype,$owndate,$parentscity,$parentsnighborhood,$nearestmosque,$jobname,$jobplace,$salary,$gotsub,$gotmarried,$wifestatus,$nekahdate,$gowithwife,$marriagedate,$nomarriagedate,$restofmoney,$datetime);
$exec = mysqli_stmt_execute($stmt);
if($exec == true){
    echo '<script type="text/javascript"> alert("تم إرسال البيانات");
             return false;
                    </script>';
} else {
    '<script type="text/javascript"> alert("حدث خطأ عند إرسال البيانات"); 
                        return false; </script>';
}
  mysqli_stmt_close($stmt);
}

配置文件

    <?php
define("HOST","localhost");
define("USER", "root");
define("PASS", "root");
define("DB", "inserted");
$con = mysqli_connect(HOST,USER,PASS,DB) or die ("error");
?>

Joomla轻松插入表格的新行: 跟随链接(使用对象)https://docs.joomla.org/Inserting,_Updateing_and_Removing_data_using_J数据库

Here the solution
// Create and populate an object.
$row = new stdClass();
$row->firstname = $_POST['firstname'];
$row->fathername = $_POST['fathername'];
.
.
. 
// Insert the object into the user profile table.
$result = JFactory::getDbo()->insertObject('#__subventions', $row);