我想注册一个人我得到了这个人的详细信息,点击注册按钮时有两个按钮我需要将详细信息存储到数据库中,当点击创建按钮时需要生成pdf.data插入完成,无论生成pdf不工作。当我单独调用create pdf按钮时,代码工作正常,我找不到为什么这不起作用
<?php
include("DBConfig/Db_connection.php");//make connection here
include("libs/fpdf.php");
if(isset($_POST['register']))
{
$url='/User_managemet/';
$todir = 'attachments/';
move_uploaded_file( $_FILES['attachments']['tmp_name'], $todir . basename($_FILES['attachments']['name'] ) );
$target_file=$url.$todir . basename($_FILES['attachments']['name'] );
$name=$_POST['name'];
$serviceNumber=$_POST['serviceNumber'];
$designation=$_POST['designation'];
$date=$_POST['date'];
$workStation=$_POST['workStation'];
$msg=$_POST['msg'];
$filepath=$target_file;
if(isset($_POST['crm']))
{
$crm='true';
$crmStatus='New';
}
else
{
$crm='false';
$crmStatus='Omit';
}
if(isset($_POST['bss']))
{
$bss='true';
$bssStatus='New';
}
else
{
$bss='false';
$bssStatus='Omit';
}
if(isset($_POST['oss']))
{
$oss='true';
$ossStatus='New';
}
else
{
$oss='false';
$ossStatus='Omit';
}
$reason=$_POST['reason'];
$insert_user="INSERT INTO `user`(`serviceNumber`,
`userName`, `designation`, `dateOfTermination`,
`workStation`, `reason`, `attachments`,
`crm`, `oss`, `bss`,
`CRM_Status`, `OSS_Status`, `BSS_Status`,
`moreInfo`) VALUES ('$serviceNumber','$name','$designation','$date','$workStation','$reason',
'$filepath','$crm','$oss','$bss','$crmStatus','$ossStatus','$bssStatus','$msg')";
$result = mysqli_query($dbcon,$insert_user);
if(!$result)
{
die('Could not get data: ' . mysqli_error());
echo '<script language="javascript">';
echo 'alert("Please try again!")';
echo '</script>';
}
else
{
echo '<script language="javascript">';
echo 'alert("Record details submitted succsesfully!")';
echo '</script>';
}
}
else if(isset($_POST['pdf']))
{
//here i need to call createpdf.php
}
else
{}
当点击pdf按钮时,我需要generatepdf,当我独立运行时,代码工作得很好n我有trid在按钮点击中添加完整代码也没有任何错误没有显示任何帮助我我也尝试使用ajax。
答案 0 :(得分:-2)
查看PDFTemplate库。它只是从Open Document文件(.odt)创建PDF文档。它是免费的,非常容易使用。您甚至可以在文档中添加占位符,并通过库填写它们。