Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 36
  1. #16
    Join Date
    Sep 2002
    Location
    Among the corn
    Posts
    10,635
    Javascript should never, ever be used for "validation", that's the job of the form processor. If the language is php, then use php to process the form.

  2. #17
    good job buddy

  3. #18

    hmmm

    very informative post, very good tutorial

  4. #19

    Question How to add Radio Buttons or Multiple Selctions Dropdown?

    Hi,

    I have been struggling to get a simple contact form (php) to include the use of radio buttons and multiple select forms.

    However, the commands in the actual contact.php form don't seem to allow the use of radio/multiple selects?

    These are OK for text fields:


    $Name = Trim(stripslashes($_POST['Name']));
    then further down the form to display in the email sent:

    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";

    But if I try to use this for a radio button etc the form just doesn't work?

    Any help much appreciated!

  5. #20
    Thanks for the tutorial

  6. #21
    very informative post, very good tutorial

  7. #22
    Join Date
    Nov 2007
    Location
    Dallas, TX
    Posts
    8,818
    Nice tutorial, and good point by linux-tech earlier in the thread about server-side validation.

    -mike
    Mike G. - Limestone Networks - Account Specialist
    Cloud, Dedicated & Enterprise Hosting - Premium Network - Passionate Support
    DDoS Protection Available - Resell Dedicated Servers @LimestoneInc - 877.586.0555

  8. #23
    Join Date
    Jul 2008
    Location
    Kansas City
    Posts
    197
    next is having it insert into a database for safe keeping, Other then that, Good job.

  9. #24

    Thanks

    Quote Originally Posted by amchost View Post
    I find this to be a great - and stable - mail script if that helps anybody.

    In case anyone was wondering, I did not write this script, so full credit goes to the original creator
    Thanks man its really working.

  10. #25
    Join Date
    Oct 2008
    Location
    Kolkata, India
    Posts
    7
    Thanks alot, its very useful tutorial.

  11. #26
    Thanks for this - just used it on one of my sites

  12. #27
    Join Date
    Jun 2006
    Location
    NY
    Posts
    484
    Is there a way to do this with TPL? My site has tpl_load for themes, and i cant find a way to make a contact script otherwise!

  13. #28
    thanks nice tut!

  14. #29
    Join Date
    Aug 2010
    Location
    Somerset, UK
    Posts
    53

    Talking

    Definitely would recommend using capcha with all contact us forms to prevent unnecessary spam.

    Also another clever trick to be used alongside form validation is to create a simple CSS rule to make a textarea's background colour change when field is wrong / blank...

    Something like this:
    PHP Code:
    .error textarea {
    background-colorred;

    Then within your PHP page, add a little something to the form element you are checking against like this:
    PHP Code:
    <textarea name="comments" <?php if($_POST[comments] == ""){ echo "class=\"error\""?>></textarea>
    This should change the background colour to red if the field is submitted as blank, simple and handy. If you are going to be using it regularly then would be worth writing a PHP function and just call it every time a form is used checking for set names such as 'email', this way you can also use regular expressions to check email is valid all in 1.

  15. #30
    Thanks for the form tutorial but it would be appreciated if you can add captcha code too for security.


    Quote Originally Posted by YouHostMe[Julie] View Post
    This is a simple script to put a contact form on your website

    Add this code to your site (This is the form)

    Code:
    <form method="POST" action="send.php">
    Fields marked (*) are required
    
    <p>Email From:* <br>
    <input type="text" name="EmailFrom">
    <p>Full Name:* <br>
    <input type="text" name="Name">
    <p>Comments:* <br>
    <input type="text" name="Comments">
    <p><input type="submit" name="submit" value="Submit">
    </form>
    <p>
    Then create a file called send.php with the following

    Code:
    <?php 
    $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
    $EmailTo = "yourname@youraddress.com";
    $Subject = "Contact Form Results";
    $Name = Trim(stripslashes($_POST['Name'])); 
    $Comments = Trim(stripslashes($_POST['Comments'])); 
    
    // validation
    $validationOK=true;
    if (Trim($EmailFrom)=="") $validationOK=false;
    if (Trim($Name)=="") $validationOK=false;
    if (Trim($Comments)=="") $validationOK=false;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $EmailFrom;
    $Body .= "\n";
    $Body .= "Comments: ";
    $Body .= $Comments;
    $Body .= "\n";
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
    }
    ?>
    Create 2 pages for your error and success pages, and name them error.html and ok.html

    Hope that helps a few people

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •