我使用FPDF以pdf格式顯示以html格式提交的數據。 我已經完成了前面提到的所有解決方案,但是我無法解決這個問題。 我發現了錯誤:如何在FPDF中刪除此錯誤?
Notice: Undefined variable: s_ name in C:\xampp\htdocs\dynamic website\form1.php on line 9 FPDF error: Some data has already been output, can't send PDF file
我的HTML代碼部分是
<td align="right" valign="top">
<label for="student3_name">3.Name </label>
</td>
<td valign="top">
<input type="text" name="student3_name" maxlength="50" size="20" >
</td>
和我form1.php如下:
<?php
if(isset($_POST['submit']))
{$s_name = $_POST["student3_name"];}
require ("fpdf/fpdf.php");
$pdf=new FPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(0,50,'',0,1);
$pdf->Cell(60,10,"hello{$s_name}",10,8,'C');
$pdf->output();
?>
編輯: 這裏是詳細部分我的表格
<form name="submission_form" method="post" action="form1.php">
<p style="text-align: center; font-size: 24px; font-weight: 900;></p>
<table width="634" align="center" border="1">
<tr>
<td align="right" valign="top">
<label for="student3_name">3.Name </label>
</td>
<td valign="top">
<input type="text" name="student3_name" maxlength="50" size="20" >
</td>
</tr>
<tr>
<td colspan="4" style="text-align:center">
<input type="submit" value="Submit"></td>
</tr>
[PHP:「通知:未定義變量」和「通知:未定義指數」]的可能重複(http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – Daan 2015-03-31 12:04:32
@Daan我已經檢查了這個問題,但是我無法使用給出的答案來解決這個問題。 – 2015-03-31 12:13:49