refresh - How to make site redirect to same page before refreshing - PHP -


i trying make user redirect #contact page before refreshing. when clicking send message site goes first page , have scroll way down #contact page , 5 seconds later refreshes first page (which good). code below:

php

<?php     if($_post['submit']){        if(!$_post['name']){       $error= "<br/>-please enter name" ;  }       if(!$_post['email']){       $error.= "<br/>-please enter email" ;     }      if (trim($_post['message']) == "") {    $error.= "<br/>-please enter message"; }     if(!$_post['contact']!=$match){       $error.= "<br/>-please enter contact number" ;     }       if ($error){       $result= "whoops, error: $error";       }      else{        mail('mahdi.mashrafi@yahoo.com', "contact message", "name: ".$_post['name']." email: ".$_post['email']."         email: ".$_post['name']."         message : ".$_post['message']."         contact :".$_post['contact'] );      //  header("location:index.php#contact");          header( "refresh:5; url = index.php#contact" ); //wait 5 seconds before redirecting            {         $result= "thankyou, ill in touch shortly";          }           }   }   ?> 

i have commented out 1 header or else $result wont show in contact form. how can make when user sends message instead of going first page redirects #contact page still displaying $result , later refresh.

from understand go #contact after submitting , 5 second later page refreshed , go #contact ?

in case, might want add #contact in form action :

<form action="mypage.php#contact"> ... </form> 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -