Loading ...
Sorry, an error occurred while loading the content.

How to unset $_POSTE value

Expand Messages
  • Ajit Tiwari
    Dear Friends I am using two files for one(enquiry.php) for form submitting & another one(enqr_mail.php) for sending this query through mail. all thing are
    Message 1 of 3 , Aug 30 5:42 AM
    • 0 Attachment
      Dear Friends

      I am using two files for one(enquiry.php) for form submitting &
      another one(enqr_mail.php) for sending this query through mail. all
      thing are right and as per my requirement, but its send the same
      mail as many times as i refresh the page this is the problem , mail
      should not send again without submitimg the form agian. I also tried to
      unset the posted value, but the problem is not resolved

      pelase help

      source code ===== enquiry.php


      <script type="text/javascript">
      function validate_form( )
      {
      valid = true ;
      if(document.enqr_form.name.value=="")
      {
      alert("Please Enter your Name");
      document.enqr_form.name.focus();
      return false;
      }


      if(document.enqr_form.email.value=="")
      {
      alert("Please Enter your E-mail");
      document.enqr_form.email.focus();
      return false;
      }

      {
      var str=document.enqr_form.email.value
      var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

      if (!filter.test(str))
      {
      alert("Please Enter a Valid E-mail address");
      document.enqr_form.email.focus();
      return false;
      }

      }

      if(document.enqr_form.comments.value =="")
      {
      alert("Please Write Your comments, without its your enquiry can't be send !");
      document.enqr_form.comments.focus();
      return false;

      }

      return true;
      }
      </script>

      <form action="enqr_mail.php" name="enqr_form" method="POST" onSubmit="return validate_form();">
      <table width="180" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#D7EBFF">
      <tr>
      <td width="10"> </td>
      <td width="160" align="left" class="black">Name*</td>
      </tr>
      <tr>
      <td> </td>
      <td align="left"><input type="text" name="name"></td>
      </tr>
      <tr>
      <td> </td>
      <td align="left" class="black">Email Address*</td>
      </tr>
      <tr>
      <td> </td>
      <td align="left"><input type="text" name="email"></td>
      </tr>
      <tr>
      <td> </td>
      <td align="left" class="black">Phone</td>
      </tr>
      <tr>
      <td> </td>
      <td align="left"><input type="text" name="phone"></td>
      </tr>
      <tr>
      <td> </td>
      <td align="left" class="black">Comments*</td>
      </tr>
      <tr>
      <td> </td>
      <td align="left">
      <textarea name="comments" cols="16" rows="5"></textarea> </td>
      </tr>
      <tr>
      <td> </td>
      <td align="center">
      <input type="submit" name="ensubmit" value="Submit"></td>
      </tr>
      </table>
      </form>

      source code ===== enqr_mail.php
      ============================

      <?php
      include 'header.php';
      include 'left_nav.php';
      ?>
      <link href="stylesheet.css" rel="stylesheet" type="text/css" />
      <td width="592" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
      <td height="32" colspan="2" valign="bottom"
      background="images/heading-degn.jpg"><table width="99%"
      border="0" cellspacing="0" cellpadding="0">
      <tr>
      <td width="52"> </td>
      <td width="448" class="orng1">Enquiry Status </td>
      </tr>
      </table></td>
      </tr>
      <tr>
      <td height="6" colspan="2"></td>
      </tr>
      <tr>
      <td height="1" colspan="2" bgcolor="#CCCCCC"></td>
      </tr>
      <tr>
      <td width="409" valign="top"><table width="99%" border="0" cellspacing="0" cellpadding="2">
      <tr>
      <td colspan="2"><div align="justify">
      <table cellpadding="0" cellspacing="0" class="maintext">
      <tr>
      <td valign="top"><p>

      <?php
      if (isset($_POST['name']))
      {

      $to="ajit.tiwari@...";
      $sender_name=$_POST['name'];
      $sender_email=$_POST['email'];
      $sender_phone=$_POST['phone'];

      $subject="Enquiry";
      $message = $_POST['comments'];
      $message =wordwrap($message, 70);
      $message = "Sender's Details : " . "\r\n\n" . "Name : " .
      $sender_name . "\r\n" . "Email-ID : " . $sender_email . "\r\n" .
      "Phone No. : " . $sender_phone . "\r\n\n\n" . $message;
      $headers ="From: <".$sender_email.">\r\n";

      if (mail($to, $subject, $message, $headers))
      {
      echo "Thanks! Your Enquiry Sent Succesfully we will response very soon";
      unset($_POST['name']);
      exit();
      }
      else

      {
      echo "Sorry ! Your Enquiry could not send right now, please try now ";
      unset($_POST['name']);
      exit();
      }
      }

      else

      {
      echo " Invalid use, firest please fiiled up the Enquiry form ";
      unset($_POST['name']);
      exit();
      }

      ?>

      </p>
      </td>
      </tr>
      </table>
      </div></td>
      </tr>

      </table>
      <p> </p></td>
      <td width="191" valign="top"><table width="188" border="0" cellspacing="0" cellpadding="0">
      <tr>
      <td><div align="center"><img
      src="images/call-us.jpg" width="168" height="90"
      /></div></td>
      </tr>
      <tr>
      <td> </td>
      </tr>
      <tr>
      <td> </td>
      </tr>
      </table></td>
      </tr>
      <tr>
      <td colspan="2"> </td>
      </tr>

      </table></td></tr>
      <?php
      include 'botfile.php';
      ?>


      regards
      Ajit





      [Non-text portions of this message have been removed]
    • Harsha M V
      write the script such that when its referer is the form submission file only then it should send the mail. so tht when u refresh... it should either return to
      Message 2 of 3 , Aug 31 1:43 AM
      • 0 Attachment
        write the script such that when its referer is the form submission file only
        then it should send the mail. so tht when u refresh... it should either
        return to the forum are show a message
        --
        Harsha M V
        {http://hmv.co.in}


        [Non-text portions of this message have been removed]
      • Vijay Srinivas
        Try checking the $_POST[ submit ] button, if it is set. If this is not set, then the email should not be sent. Vijay Srinivas ... From: Harsha M V
        Message 3 of 3 , Sep 11, 2008
        • 0 Attachment
          Try checking the $_POST['submit'] button, if it is set. If this is not set, then the email should not be sent.
          Vijay Srinivas

          --- On Sun, 8/31/08, Harsha M V <hmvrulz@...> wrote:
          From: Harsha M V <hmvrulz@...>
          Subject: Re: [bang-phpug] How to unset $_POSTE value
          To: bang-phpug@yahoogroups.com
          Date: Sunday, August 31, 2008, 2:13 PM











          write the script such that when its referer is the form submission file only

          then it should send the mail. so tht when u refresh... it should either

          return to the forum are show a message

          --

          Harsha M V

          {http://hmv.co in}



          [Non-text portions of this message have been removed]





























          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.