3 Replies Latest reply on Jul 23, 2014 3:03 AM by osgood_

    Feedback form Problem

    admin Level 2

      Hello Adobe Communities, this is my first time here and I probably will be back here again.

      How do I make my Feedback Form (coding shown below) send an email when the user clicks 'Submit' to 'expertpcguides@gmail.com'

      Thanks for your help. On a side note if the user clicks 'submit' too many times can you make it so it won't send that email address notifications anymore.

      Note that: I'm using Adobe Dreamweaver CS3

       

        <p class="style8">Feedback Form</p>

          <form id="form1" name="form1" method="post" action="">

            <label><strong>Suggest Feedback:</strong><br />

            <br />

            <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>

            </label>

            <p><strong>Rate this site honestly:</strong><br />

      </p>

            <p>

              <label>

              <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_0" />

      Great</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_1" />

      Good</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_2" />

      Average</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_3" />

      Bad</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_4" />

      Horrible</label>

              <br />

            </p>

          </form>

          <form id="form2" name="form2" method="post" action="">

            <label>

            <input type="submit" name="Submit" id="Submit" value="Submit" />

            </label>

          </form>

          <h1> </h1>

          <p></p>

        • 1. Re: Feedback form Problem
          osgood_ Level 8

          You really need to use some server language scripting to process the form, like php. If your host server supports php then copy the below, paste into a Dreamweaver document and save it as - feedback.php (the file has to have a .php extension NOT .html for it to work). Upload it to your server and test (or if you are running a local server test it on that). It's a basic solution which will gather the information from the form and send it to a specified email address (insert that where you see marked in red in the code).

           

          <?php

          if (isset($_POST['Submit'])) {

          // get feeback

          $textarea = stripslashes(trim($_POST['textarea']));

          // get ratings

          $rating = trim($_POST['RadioGroup1']);

          // get email address

          $email = trim($_POST['email']);

          // build the message

          $to = "XXXXXX@XXXXXXXX.XXXXX.XXX";

          $subject   = "Comments from website";

          $headers  = "From: $email\r\n";

          $headers .= "Reply-To: $email\r\n";

          $message = "Suggested Feedback: $textarea\n\n";

          $message .= "Rating: $rating\n\n";

          $message .= "Email: $email\n\n";

          mail($to, $subject, $message, $headers);

          $sent = "Mail was sent successfully";

          }

          ?>

          <!DOCTYPE HTML>

          <html>

          <head>

          <meta charset="UTF-8">

          <title>Website Form</title>

          </head>

           

          <body>

           

          <?php

          if(isset($sent)) {

              echo "<h3>$sent</h3>";

          }

              ?>

          <form id="form1" name="form1" method="post" action="feedback.php">

          <label><strong>Suggest Feedback:</strong><br />

          <br />

          <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>

          </label>

          <p><strong>Rate this site honestly:</strong><br /></p>

          <p>

          <label>

          <input type="radio" name="RadioGroup1" value="Great" id="RadioGroup1_0" />

          Great</label>

          <br />

          <label>

          <input type="radio" name="RadioGroup1" value="Good" id="RadioGroup1_1" />

          Good</label>

          <br />

          <label>

          <input type="radio" name="RadioGroup1" value="Average" id="RadioGroup1_2" />

          Average</label>

          <br />

          <label>

          <input type="radio" name="RadioGroup1" value="Bad" id="RadioGroup1_3" />

          Bad</label>

          <br />

          <label>

          <input type="radio" name="RadioGroup1" value="Horrible" id="RadioGroup1_4" />

          Horrible</label>

          <br />

          <br />

          <label>

          Email Address<br />

          <input type="text" name="email"  id="email" />

          </label>

           

          </p>

          <p>

          <label>

          <input type="submit" name="Submit" id="Submit" value="Submit" />

          </label>

          </p>

          </form>

          </body>

          </html>

          • 2. Re: Feedback form Problem
            osgood_ Level 8

            CoreyFS wrote:

             

            On a side note if the user clicks 'submit' too many times can you make it so it won't send that email address notifications anymore.

             

             

             

            You would need to store the email address in a database and check it against the email address submitted from the form. If its already in the database don't send the mail. You could set the email address in the database to automatically expire at a specific time in the future.

             

            Of course if you don't know about setting up databases it is going to be difficult for you to do........for someone that does its probably an hours work if that.

             

             

            EDITED:

             

            Re-reading this you most probably need to set a php 'cookie' for the session: Prevent multiple form submissions

             

            With the addition of the 'cookie' the code below will most probably be all you need:

             

             

            <?php

                /* Prevent duplicate submissions */

            if (isset($_COOKIE['FormSubmitted']))

            {

            $error = "Sorry you have already voted!";

            }

            elseif(isset($_POST['Submit'])) {

                // get feeback

            $textarea = stripslashes(trim($_POST['textarea']));

            // get ratings

            $rating = trim($_POST['RadioGroup1']);

            // get email address

            $email = "myWebServer.com";

            // build the message

            $to = "XXXXXX@XXXXXXXX.XXXXX.XXX";

            $subject = "Vote from website";

            $headers  = "From: $email\r\n";

            $headers .= "Reply-To: $email\r\n";

            $message = "Suggested Feedback: $textarea\n\n";

            $message .= "Rating: $rating\n\n";

            mail($to, $subject, $message, $headers);

            /* Set a cookie to prevent duplicate submissions */

            setcookie('FormSubmitted', '1');

            $sent = "Feedback was sent successfully";

            }

            ?>

            <!DOCTYPE HTML>

            <html>

            <head>

            <meta charset="UTF-8">

            <title>Website Form</title>

            </head>

             

            <body>

             

            <?php

            if(isset($sent)) {

                echo "<h3>$sent</h3>";

            }

            if(isset($error)) {

            echo "<h3>$error</h3>";

            }

            ?>

            <form id="form1" name="form1" method="post" action="feedback.php">

            <label><strong>Suggest Feedback:</strong><br />

            <br />

            <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>

            </label>

            <p><strong>Rate this site honestly:</strong><br /></p>

            <p>

            <label>

            <input type="radio" name="RadioGroup1" value="Great" id="RadioGroup1_0" />

            Great</label>

            <br />

            <label>

            <input type="radio" name="RadioGroup1" value="Good" id="RadioGroup1_1" />

            Good</label>

            <br />

            <label>

            <input type="radio" name="RadioGroup1" value="Average" id="RadioGroup1_2" />

            Average</label>

            <br />

            <label>

            <input type="radio" name="RadioGroup1" value="Bad" id="RadioGroup1_3" />

            Bad</label>

            <br />

            <label>

            <input type="radio" name="RadioGroup1" value="Horrible" id="RadioGroup1_4" />

            Horrible</label>

            </p>

            <p>

            <label>

            <input type="submit" name="Submit" id="Submit" value="Submit" />

            </label>

            </p>

            </form>

            </body>

            </html>

            1 person found this helpful
            • 3. Re: Feedback form Problem
              osgood_ Level 8

              You can just select all of the code I supplied and insert it as it will create double tags which you don't want.

               

              Copy the first block of code below and paste it at the very top of your page BEFORE anything else. (change the XXXXXXX's to your email address)

               

              <?php

                  /* Prevent duplicate submissions */

              if (isset($_COOKIE['FormSubmitted']))

              {

              $error = "Sorry you have already voted!";

              }

              elseif(isset($_POST['Submit'])) {

                  // get feeback

              $textarea = stripslashes(trim($_POST['textarea']));

              // get ratings

              $rating = trim($_POST['RadioGroup1']);

              // get email address

              $email = "myWebServer.com";

              // build the message

              $to = "XXXXXX@XXXXXXXX.XXXXX.XXX";

              $subject = "Vote from website";

              $headers  = "From: $email\r\n";

              $headers .= "Reply-To: $email\r\n";

              $message = "Suggested Feedback: $textarea\n\n";

              $message .= "Rating: $rating\n\n";

              mail($to, $subject, $message, $headers);

              /* Set a cookie to prevent duplicate submissions */

              setcookie('FormSubmitted', '1');

              $sent = "Feedback was sent successfully";

              }

              ?>

               

               

               

              Then copy the form code below and insert it where your form code is.

               

               

              <?php

              if(isset($sent)) {

                  echo "<h3>$sent</h3>";

              }

              if(isset($error)) {

              echo "<h3>$error</h3>";

              }

              ?>

              <form id="form1" name="form1" method="post" action="">

              <label><strong>Suggest Feedback:</strong><br />

              <br />

              <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>

              </label>

              <p><strong>Rate this site honestly:</strong><br /></p>

              <p>

              <label>

              <input type="radio" name="RadioGroup1" value="Great" id="RadioGroup1_0" />

              Great</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="Good" id="RadioGroup1_1" />

              Good</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="Average" id="RadioGroup1_2" />

              Average</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="Bad" id="RadioGroup1_3" />

              Bad</label>

              <br />

              <label>

              <input type="radio" name="RadioGroup1" value="Horrible" id="RadioGroup1_4" />

              Horrible</label>

              </p>

              <p>

              <label>

              <input type="submit" name="Submit" id="Submit" value="Submit" />

              </label>

              </p>

              </form>