i tried refreshing the page using header but it didnt work.. header .. my "the 9th line from the bottom... thanks in anticipation of your replies

<form name="page" method="POST" action="page.php">
   <fieldset>


      <label for="name" id="name_label">Name</label>
      <br />
      <input type="text" name="name" id="name" size="30" value="" class="text-input" />
      <label class="error" for="name" id="name_error">This field is required.</label>
      <br />
      <label for="email" id="email_label"> Email</label>
      <input type="text" name="email" id="email" size="30" value="" class="text-input" />
      <label class="error" for="email" id="email_error">This field is required.</label>
      <br />

      <label for="phone" id="phone_label">Phone</label>
      <input type="text" name="phone" id="phone" size="30" value="" class="text-input" />
      <label class="error" for="phone" id="phone_error">This field is required.</label>

        <br />
        <label for="comments" id="comments"> Comments</label>
        <textarea name="comments" cols = "45" rows ="10"> </textarea>
        <label class="error" for ="comments" id="comments_error">    </label>
        <br />

      <input type="submit" name="submit" class="button"  value="Send" />


  </fieldset>
 </form>
</body>
</html>
<?php
if($_SERVER['REQUEST_METHOD']=='POST'
&& $_POST['submit']=='Send'
&& !empty($_POST['name'])
&& !empty($_POST['email'])
&& !empty($_POST['phone'])
)

{


$sql = "INSERT INTO contact_us_db (name, email,phone,comments) VALUES ('$_POST[name]' ,  '$_POST[email]' ,'$_POST[phone]' , '$_POST[comments]' )";
$stmt = $db->prepare($sql);
$stmt->execute(array($name, $email,$phone,$comments));
$stmt->closeCursor();

$id_obj = $db->query("SELECT LAST_INSERT_ID()");
$id = $id_obj->fetch();
$id_obj->closeCursor();
// Send the user to the new entry
header('Location: ../contact_us1.php?id='.$id[0]);
exit;

}

{


exit;
}
?>

You should only use header if nothing has been outputted already. You can fix it if you move your if to the top of the file. Next time please use code tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.