Web Analytics Made Easy -
StatCounter PHP Mail form with validation? - CodingForum

Announcement

Collapse
No announcement yet.

PHP Mail form with validation?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP Mail form with validation?

    I've looked all over for a PHP mail form that has validation and makes sense. Since I am very new to php, does anyone know of a place/script that will do this?

  • #2
    i have one but please tell me what your definition of validation is
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    There are 3 kinds of ppl those who can count and those who cant
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Script-Megafest.com Coming Oh so very soon

    Comment


    • #3
      Maybe you can adjust this one to fit your needs. It has javascript and server side validation.
      Attached Files
      ||||If you are getting paid to do a job, don't ask for help on it!||||

      Comment


      • #4
        Originally posted by Al_90
        i have one but please tell me what your definition of validation is
        Just like checking to make sure that they input an email adress and a message.

        Comment


        • #5
          Originally posted by _Aerospace_Eng_
          Maybe you can adjust this one to fit your needs. It has javascript and server side validation.
          I can't figure it out.

          The validation doesnt work with my page setup.

          I just have

          <?php include(" headers.php") ?>

          this is the page

          <?php include ("footers.php") ?>

          Comment


          • #6
            aight, i got 1 that does dat, here it is:
            PHP Code:
            <?php if($_GET['contact']) {
            $to         "[email protected]";
            $fname       $_POST['fname'];
            $lname       $_POST['lname'];
            $email        $_POST['email'];
            $mesage   $_POST['mesage'];
            $sub        "Contact email form yoursitename";
            $headers    "From: $fname $lname <$email>\n";  
            $headers   .= "Content-Type: text/plain; charset=iso-8859-1\n";
            $mes        "First Name: ".$fname."\n";
            $mes       .= "Last Name: ".$lname."\n";
            $mes       .= "Email: ".$email."\n";
            $mes       .= "Message: ".$mesage."\n";
            if(empty(
            $fname) || empty($lname) || empty($email) || empty($mesage)) {
                 echo 
            " <h3><center>Please fill out all the fields</center></h3>";
            } elseif(!
            ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$email)) {
                 print 
            "   <<h3><center>Sorry the email address you entered looks like it's invalid</center></h3>";
            } else {
                 
            mail($to$sub$mes$headers);
                 print 
            "   <h3><center>Thank you. ".$fname." we will respond within 24-48 hours </center></h3>";
            }
            }
            ?>
            <form method="post" action="?contact=true">
            <div align="center">
            First Name:&nbsp;<input name="fname" type="text" size="30"><br>
            Last Name:&nbsp;<input name="lname" type="text" size="30"><br>
            Email:&nbsp;<input name="email" type="text" size="30"><br>
            Message:<br><textarea name="mesage" cols="50" rows="5"></textarea>
            <br>
            </div>
            </form>
            you jus need to input it into an html page and save it with e .php extention
            -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
            There are 3 kinds of ppl those who can count and those who cant
            -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
            Script-Megafest.com Coming Oh so very soon

            Comment


            • #7
              Originally posted by Al_90
              aight, i got 1 that does dat, here it is:
              PHP Code:
              <?php if($_GET['contact']) {
              $to         "[email protected]";
              $fname       $_POST['fname'];
              $lname       $_POST['lname'];
              $email        $_POST['email'];
              $mesage   $_POST['mesage'];
              $sub        "Contact email form yoursitename";
              $headers    "From: $fname $lname <$email>\n";  
              $headers   .= "Content-Type: text/plain; charset=iso-8859-1\n";
              $mes        "First Name: ".$fname."\n";
              $mes       .= "Last Name: ".$lname."\n";
              $mes       .= "Email: ".$email."\n";
              $mes       .= "Message: ".$mesage."\n";
              if(empty(
              $fname) || empty($lname) || empty($email) || empty($mesage)) {
                   echo 
              " <h3><center>Please fill out all the fields</center></h3>";
              } elseif(!
              ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$email)) {
                   print 
              "   <<h3><center>Sorry the email address you entered looks like it's invalid</center></h3>";
              } else {
                   
              mail($to$sub$mes$headers);
                   print 
              "   <h3><center>Thank you. ".$fname." we will respond within 24-48 hours </center></h3>";
              }
              }
              ?>
              <form method="post" action="?contact=true">
              <div align="center">
              First Name:&nbsp;<input name="fname" type="text" size="30"><br>
              Last Name:&nbsp;<input name="lname" type="text" size="30"><br>
              Email:&nbsp;<input name="email" type="text" size="30"><br>
              Message:<br><textarea name="mesage" cols="50" rows="5"></textarea>
              <br>
              </div>
              </form>
              you jus need to input it into an html page and save it with e .php extention

              I got it working, I just had to put all the code onto the contact page instead of using includes.
              Last edited by Ranger56; Aug 3, 2005, 05:14 PM.

              Comment


              • #8
                mine or his?
                -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                There are 3 kinds of ppl those who can count and those who cant
                -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                Script-Megafest.com Coming Oh so very soon

                Comment


                • #9
                  Originally posted by Al_90
                  mine or his?

                  Yours.

                  http://www.spiderseatbabies.com/swee/other.php

                  Comment


                  • #10
                    looks nice, glad i could help
                    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    There are 3 kinds of ppl those who can count and those who cant
                    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    Script-Megafest.com Coming Oh so very soon

                    Comment

                    Working...
                    X