Why is browser opening a new window? (HTML, PHP) -


i'm trying present "message sent successfully" message on page using php output javascript gets paragraph element id , inserts text in it.

but reason instead of happening expected browser opening new window (and presumeably outputting code @ point).

can tell me why it's opening new browser , how can stop it? haven't been able figure out in looking.

also, i'm using bootstrap 3 framework - why?

thanks help.

    <?php /* set e-mail recipient */ $myemail = "hello@madeupemail.com";  /* check form inputs using check_input function */ $name = check_input($_post['inputname'], "name"); $email = check_input($_post['inputemail'], "email"); $phone = check_input($_post['inputphone'], "phone"); $message = check_input($_post['inputmessage'], "enter message here");  /* if e-mail not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("invalid e-mail address"); } /* let's prepare message e-mail */  $subject = "someone has sent message";  $message = "  has sent message using contact form:  name: $name email: $email phone: $phone  message: $message  ";  /* send message using mail() function */ mail($myemail, $subject, $message);  /* redirect visitor thank page */ echo '<script type="text/javascript">'    , 'document.getelementbyid("contactformtest").innerhtml = "the mail sent successfully";'    , '</script>' ;  /* functions used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; }  function show_error($myerror) { ?> <html> <body>  <p>please correct following error:</p> <strong><?php echo $myerror; ?></strong> <p>hit button , try again</p>  </body> </html> <?php exit(); } ?> 

html

    <p id="contactformtest"></p> <form class="form-horizontal" method="post" action="php/mailer.php" role="form">                         <fieldset>                             <div class="col-md-3"></div><!-- col-md-3 -->                             <div class="col-md-6">                                  <div class="form-group">                                     <div class="col-md-12">                                         <input id="inputname" name="inputname" type="text" placeholder="name" class="form-control">                                     </div><!-- col-md-12 -->                                 </div><!-- form-group -->                                  <div class="form-group">                                     <div class="col-md-12">                                         <input id="inputemail" name="inputemail" type="text" placeholder="email" class="form-control">                                     </div><!-- col-md-12 -->                                 </div><!-- form-group -->                                  <div class="form-group">                                     <div class="col-md-12">                                         <input id="inputphone" name="inputphone" type="text" placeholder="phone" class="form-control">                                     </div><!-- col-md-12 -->                                 </div><!-- form-group -->                                  <div class="form-group">                                     <div class="col-md-12">                                         <textarea class="form-control" id="inputmessage" name="inputmessage" placeholder="enter message here" rows="7"></textarea>                                     </div><!-- col-md-12 -->                                 </div><!-- form-group -->                                  <div class="form-group">                                     <div class="col-md-12 text-center">                                         <button type="submit" class="btn btn-primary btn-md">submit</button>                                     </div><!-- col-md-12 -->                                 </div><!-- form-group -->                             </div><!--  col-md-6 -->                              <div class="col-md-3"></div><!-- col-md-3 -->                         </fieldset>                     </form> 

have tried adding "target" attribute in tag this,

<form class="form-horizontal" target="_self" method="post" action="php/mailer.php" role="form"> 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -