I have a form on a page to submit a comment, and once a user places a comment I would like it to reload the page.

This is what I got

      $insertGoTo = "employer.php?employer=" . $row_employer_page['employer'] . "";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $insertGoTo));

It works, however I got this error on submit.

    Notice: Undefined variable: row_employer_page in /u/students/m/*******/public_html/cis231/project/employer.php on line 51

Warning: Cannot modify header information - headers already sent by (output started at /u/students/m/*******/public_html/cis231/project/employer.php:51) in /u/students/m/*******/public_html/cis231/project/employer.php on line 56

The lines it references are the code I posted above. I'm not sure what's going on, it reload the page how I want but throws that error

我在页面上有一个表单提交评论,一旦用户发表评论,我希望它 重新加载页面。 p>

这就是我得到的 p>

  $ insertGoTo =“employer.php?employer =”。  $ row_employer_page ['雇主']。  “”; 
 if(isset($ _ SERVER ['QUERY_STRING'])){
 $ insertGoTo。=(strpos($ insertGoTo,'?'))?  “&安培;”  :“?”; 
 $ insertGoTo。= $ _SERVER ['QUERY_STRING']; 
标题(sprintf(“位置:%s”,$ insertGoTo)); 

它有效,但我在提交时遇到此错误。 p>

警告:无法修改标题信息 - 已经发送的标题(输出从/u/students/m/*******/public_html/cis231/project/employer.php:51开始)/ u / students / m 第56行上的/*******/public_html/cis231/project/employer.php 
  code>  pre> 

它引用的行是我上面发布的代码。 我不确定发生了什么,它重新加载页面我想要的但却抛出了这个错误 p> div>

 2 条回答