Page 1 of 1

Contact form problem

Posted: Wed Jul 16, 2014 11:26 am
by gautamz07
need help with contact page.

i am very new to PHP , my contact form works fine , except when the user is re-directed to the next page , and presses the back button , his/her details still show up in form when he comes to the main page . how to erase those details ? once he's clicked on the send button ?

I have the following HTML code

Code: Select all

<section class="contactpage" id="contactus">

    <div class="container">
        <div class="row">

            <div class="col-md-4">

            <form class="well" style="padding-bottom:0px;" action="send.php" method="POST">

            <div class="form-group">

              <label class="control-label pull-left" for="inputEmail"><i class="glyphicon glyphicon-user"></i>  
                 Full Name</label>
              <div class="controls controls-row">
                  <input name="name" type="text" class="input-xxlarge form-control" id="inputEmail" placeholder="Enter your name">

              </div>
                
            </div>

            <div class="form-group">

              <label class="control-label pull-left" for="inputEmail"><i class="glyphicon glyphicon-phone-alt"></i> Mobile Number</label>
              <div class="controls controls-row">
                  <input name="phone" type="text" class="input-xxlarge form-control" id="inputEmail" placeholder="Enter your contact number">

              </div>
                
            </div>

            <div class="form-group">

                <label class="control-label pull-left" for="inputEmail"><i class="glyphicon glyphicon-envelope"></i> Email</label>
                <div class="controls">
                  <input name="email" type="text" class="input-xxlarge form-control" id="inputEmail" placeholder="Enter your email">
                </div>

            </div>

            <!--Check-Boxes come here  -->


            <div class="form-group">

              <label class="control-label pull-left" for="inputEmail"><i class="glyphicon glyphicon-comment"></i> Message</label>
              <div class ="controls">
                <textarea name="message" rows="6" class="input-xxlarge form-control" placeholder="Enter message"></textarea>
              </div>

            </div>
<!-- 
            <div class="extra-wth form-group">

              <label class="control-label pull-left" for="Interest">Interest</label>
              <div class="controls pull-left">
              
              <label class="radio-inline">
                <input type="radio" name="interest" value="optional" /> Enquiry 
              </label>
              
              <label class="radio-inline">
                <input type="radio" name="interest" value="optiona2" /> Feedback
              </label>
              
              <label class="radio-inline">
                <input type="radio" name="interest" value="optiona3" /> business oppotunity
              </label>

            </div>

              
            </div> -->

    <div class="form-group">
    <div class="controls">
      <button type="submit" class="btn btn-success">Send Message</button>
    </div>
  </div>
  <br/></br/>
  </form>
 
</div>

and the following PHP code for the page that re-directs

Code: Select all

<!DOCTYPE html>
<html>
  <head>
    <title>title</title>

    <!-- Font Link starts -->
    <!-- <link href='http://fonts.googleapis.com/css?family=Playfair+Display' rel='stylesheet' type='text/css'>  -->  
    <link href='http://fonts.googleapis.com/css?family=Delius' rel='stylesheet' type='text/css'>
    <!-- <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Tangerine"> -->
    <link href='http://fonts.googleapis.com/css?family=Dancing+Script:700' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Tangerine:700' rel='stylesheet' type='text/css'>
    
    <!-- Fevicon Link -->
    <link rel="shortcut icon" href="favicon.ico"/>

    <!-- Font Links end -->
    <link type="text/css" rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css" />    

    <!-- css/bootstrap.css -->
    
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="stylesheet" type="text/css" href="css/grayscale.css">
    <link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />

    <!-- Greysacle css file below -->


  

  </head>
  <body>
  
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
     //$to = 'sil.dotfront@gmail.com';
     $to = 'me.dotfront@gmail.com';
     $subject = 'Enquiry From';
     $name = $_POST['name'];
     $phone = $_POST['phone'];
     $email = $_POST['email'];
     $message = $_POST['message'];
         
         if(!empty($name)&&!empty($phone)&&!empty($email)&&!empty($message)) {
       $body = "Name:".$name."<br>";
          $body .= "Phone:".$phone."<br>";
          $body .= "Email:".$email."<br>";
          $body .= "Message:".$message."<br>";

          $headers  = 'MIME-Version: 1.0' . "\r\n";
          $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

          // Additional headers
          $headers .= 'From: Lead<info@dotfront.net>' . "\r\n";
          $headers .= 'Bcc: info@purplefront.net' . "\r\n";
          // $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

          if(mail($to, $subject, $body, $headers)){
          ?>
          <div style="background-color:green; color:#FFF;" class='success'><h4>Thank you for submitting! We will get back to you shortly.</h4></div>
          <?php
               //$output = "Thanky you for Submitting! We will get bake to you shortly.";          
          }
       }else{
          ?>
          <div style="background-color:red; color:#FFF;" class='success'><h4>Something went wrong please submit again</h4></div>
          <?php
          }
}
?>
  </body>
</html>

Re: Contact form problem

Posted: Fri Sep 05, 2014 4:01 am
by Elasek
set the value to be empty.
ex. <input name="email" type="text" class="input-xxlarge form-control" id="inputEmail" placeholder="Enter your email" value="">
most simple solution imo.

Re: Contact form problem

Posted: Fri Sep 19, 2014 12:18 am
by ahmad20
I have the following...........M............