javascript - Resubmitting Error in PHP Conatct form -


apologies bad english. in php contact form while fill out contents , submit, echo message showing.

while try refresh “confirm form resubmission” showing along message "the mail has been sent successfully".

i need code when submitted contact form after refresh page won't display echo message along confirm re-submission message.

i starting out php , not familiar it. can me please.

php script

<?php  session_start();  if(isset($_post['submit']) && $_post['randcheck']==$_session['rand']) {  $your_name = $_request['your_name'];  $email = $_request['email'];  $mobile_number = $_request['mobile_number'];  $message = $_request['message'];  $formcontent="from: $your_name \n email: $email \n phone number: $mobile_number \n message: $message";  $to = "mail@hotmail.com";  $subject = "contact form";  $mailheader = "from: $email \r\n";       if (($your_name=="")||($email=="")||($message==""))         {         $msg = "all fields required";         }     else{                mail($to,$subject,$formcontent,$mailheader);          $msg = "the mail has been sent successfully";         }     }    ?> 

html script

<?php    $rand=rand();    $_session['rand']=$rand; ?>  <input type="hidden" value="<?php echo $rand; ?>" name="randcheck" />  <form name="contactform" method="post" enctype="multipart/form-data">        <label for="your_name">your name <font color="red">*</font></label>       <input  type="text" name="your_name"  placeholder="enter name" maxlength="20" size="40" value="">        <label for="email">email address <font color="red">*</font></label>       <input  type="email" name="email" placeholder=" enter e-mail address" maxlength="20" size="40" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" required value="">        <label for="mobile_number">mobile number</label>       <input  type="tel" name="mobile_number" pattern="[0-9]{1}[0-9]{9}" placeholder="enter phone number adding country code (eg: +91.,)" maxlength="30" size="40" value="">        <label for="message">message <font color="red">*</font></label>       <textarea  name="message" placeholder="your message goes here" maxlength="1000" cols="62" rows="10" required></textarea>          <input type="submit" name="submit" value="submit">        <div class="mail"> <?php echo $msg; ?> </div>         </form> 

you should redirect after submitting, if refresh page go redirect:

header('location:  / new.php'); exit; 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -