Php 为什么我在文本框中得到奇怪的值?

Php 为什么我在文本框中得到奇怪的值?,php,mysql,Php,Mysql,这段代码有什么问题,它在主题和消息文本框中都显示了奇怪的值,但它们应该是空的。服务器正在给我未定义的变量错误调用堆栈#TimeMemoryFunctionLocation某物。请看一看,我是php初学者。请帮我去掉文本框中的那些值。它们应该是空的 <?php if (isset($_POST['submit'])) { $from = 'drstoic@xyz.com'; $subject = $_POST['subject']; $text = $_POST['newsletter_co

这段代码有什么问题,它在主题和消息文本框中都显示了奇怪的值,但它们应该是空的。服务器正在给我未定义的变量错误调用堆栈#TimeMemoryFunctionLocation某物。请看一看,我是php初学者。请帮我去掉文本框中的那些值。它们应该是空的

<?php
if (isset($_POST['submit'])) {
$from = 'drstoic@xyz.com';
$subject = $_POST['subject'];
$text = $_POST['newsletter_content'];
$output_form = false;

if (empty($subject) && empty($text)) {
// We know both $subject AND $text are blank 
  echo 'You forgot the email subject and body text.<br />';
  $output_form = true;
}

if (empty($subject) && (!empty($text))) {
  echo 'You forgot the email subject.<br />';
  $output_form = true;
}

if ((!empty($subject)) && empty($text)) {
  echo 'You forgot the email body text.<br />';
  $output_form = true;
}
}
else {
$output_form = true;
}

  if ((!empty($subject)) && (!empty($text))) {
$dbc = mysqli_connect('localhost', 'root', 'a12345', 'pocr')
  or die('Error connecting to MySQL server.');

$query = "SELECT * FROM email_list";
$result = mysqli_query($dbc, $query)
  or die('Error querying database.');

while ($row = mysqli_fetch_array($result)){
  $to = $row['email'];
  $first_name = $row['first_name'];
  $last_name = $row['last_name'];
  $msg = "Dear $first_name $last_name,\n$text";
  mail($to, $subject, $msg, 'From:' . $from);
  echo 'Email sent to: ' . $to . '<br />';
} 

mysqli_close($dbc);
}
if ($output_form)
{ 
?> <form method="post"  action="<?php echo $_SERVER['PHP_SELF']; ?>"                    
<label for="subject">Subject:</label> 
<input type="text" name="subject" id="subject" class="input_field" 
value="<?php echo $subject; ?>" />
<div class="cleaner h10"></div>

<label for="newsletter_content">Message:</label> 
<textarea id="newsletter_content" name="newsletter_content" rows="0" cols="0"><?php echo $text; ?></textarea>

<div class="cleaner h10"></div>

<input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" />
<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />

</form>
<?php
}
?>

设置
$text=''$主题=“”if(isset($\u POST['submit']){
之前的页面顶部的code>可能是
中缺少的结束语
在将输入拆分为单独的行时也要小心
侧注:对于
if(isset($\u POST['submit']),您的结束括号
){
不在正确的位置。将执行该条件语句中括号内的所有内容,而忽略它之外的任何内容。OP正在使用
if(isset($\u POST['submit']))
并与
@Fred ii一起工作-OP特别提到未定义变量错误消息,在第一次查看页面时,其
value=“”
中的值将在理论之外的实践中产生警告!
<input type="text" name="subject" id="subject" class="input_field" value="<?php echo $subject; ?>" />