+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: simple php form

  1. #1
    Active Member Revenant is on a distinguished road
    Join Date
    May 2004
    Location
    Chicago, IL US of A
    Posts
    108

    simple php form

    Need a simple PHP contact form ? you've come to the right thread ...

    Step # 1 :: The form [contact.html]

    Code:
    <form action="send.php" method="post"> // we will create the file "send.php" afterwards
    
    E-mail: <input type="text" name="email" size="20"> // the email text field
    
    <br>
    
    Inquiry: <textarea name="inquiry" rows="3" cols="17"></textarea> // the inquiry text area
    
    <br>
    
    <input type="submit" value="Submit"> // the submittz0rs :D  </form>
    Next Step # 2 :: The mainframe [send.php]

    Code:
    <?
    $email=$_POST['email']; // response to the text name email
    
    $inquiry=$_POST['inquiry']; // response to the text area inquiry
    
    $to="foo@bar.com"; // Put your e-mail here
    
    $message="You've just received an inquiry from $email.
    They said:\n$inquiry\n\n"; // body text for e-mail
    
    if(mail($to,"Inquiry From Your Site ",$message,"From: $email\n")) // subject 
    
    {
    echo "
    <head>
    <link rel='stylesheet' type='text/css' href='../css.css'>
    </head>thanks for submitting the stuff, have a cheery day"; // Page that comes up after submission
    
    
    } else {
    echo "if you got an issue. i can't afford a tissue."; } // comes up if something goes wrong
    ?>
    and thats it, if you get an error, just tell me, im sure there is one cuz i had to write this up in like 5 minutes
    // Rev
    // Ivan Alfaro
    -- Professional Web Developer

  2. #2
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75
    Nice to begin with

    But I would not recommend using this for production. For sure, someone would try to flood you...

  3. #3
    Active Member Revenant is on a distinguished road
    Join Date
    May 2004
    Location
    Chicago, IL US of A
    Posts
    108
    why's that ?
    // Rev
    // Ivan Alfaro
    -- Professional Web Developer

  4. #4
    Full Member wicked_gal00 is on a distinguished road
    Join Date
    May 2004
    Location
    Canada
    Posts
    56
    Originally posted by ZYV
    Nice to begin with

    But I would not recommend using this for production. For sure, someone would try to flood you...
    Do you mean because he left his email there, and maybe people will copy/paste without changing it?
    Cheap Web/Flash Design!
    Portfolio:http://liquifiedblue.com
    AIM: blueshiver001
    Email: alexb86@gmail.com

  5. #5
    Full Member Marshall is on a distinguished road
    Join Date
    May 2004
    Posts
    69
    I think he means because there is no timer set on how many emails a person could send, someone could just keep refreshing the submitted page and resubmit the data which sends another email over and over and will flood your inbox with useless emails. You should add some way to make like only 1 email per an hour using either cookies or a database with their ip and a timer.

  6. #6
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75
    Yeah, that's exactly what I meant to say.

  7. #7
    Active Member Revenant is on a distinguished road
    Join Date
    May 2004
    Location
    Chicago, IL US of A
    Posts
    108
    dah, well if that happens...just give that flooder a beating, and viola.

    // Rev
    // Ivan Alfaro
    -- Professional Web Developer

  8. #8
    Active Member WorldBuilder is on a distinguished road
    Join Date
    Jan 2004
    Location
    Boston, MA
    Posts
    366
    Originally posted by ZYV
    Yeah, that's exactly what I meant to say.
    ZYV, since I am learning php, I would like to ask how you would fix this issue (of no limit on resubmitting)? Besides, the other members could benefit.

    Chris
    My Site | My Blog
    "The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing."
    "Insanity is doing the same thing over and over again, expecting different results"
    --Albert Einstein

  9. #9
    Active Member Revenant is on a distinguished road
    Join Date
    May 2004
    Location
    Chicago, IL US of A
    Posts
    108
    not to budge in, but im pretty sure i can do it by saving the ip of the person into a text file and blocking them from using it again...of course this can be a problem because they wouldnt be able to resubmit an application unless their ip is static.
    // Rev
    // Ivan Alfaro
    -- Professional Web Developer

  10. #10
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75
    Revenant, you can continue like that, but don't complain when you find 30000 messages in your mailbox then

    Chris, just do something like that:

    PHP Code:
    <?php

    $email
    =$_POST['email']; // response to the text name email
    $inquiry=$_POST['inquiry']; // response to the text area inquiry
    $to="foo@bar.com"// Put your e-mail here
    $message="You've just received an inquiry from $email. They said:\n$inquiry\n\n"// body text for e-mail

    if(
    (!isset(
    $_COOKIE['foo_bar'])) 
    && 
    mail($to,"Inquiry From Your Site ",$message,"From: $email\n") )  {

    setcookie ("foo_bar""true"time() + 3600); 

    echo 
    "<head><link rel='stylesheet' type='text/css' href='../css.css'></head>thanks for submitting the stuff, have a cheery day"// Page that comes up after submission


    } else {
       echo 
    "if you got an issue. i can't afford a tissue."
    // comes up if something goes wrong
    ?>
    That should work with short-circuit evaluation enabled, other wise just add a nested if (cookie) { ... } . That's much better than nothing but logging the IP would be better (although a little harder, as you will need to store IPs in the DB or plaintext file)...

  11. #11
    Active Member Revenant is on a distinguished road
    Join Date
    May 2004
    Location
    Chicago, IL US of A
    Posts
    108
    Sure is complicated, I'll be working on a script to ban ip's from submitting again...So far, it will be a big file. I'll post it as an attachment when I'm done...Just got to finish all my other projects
    // Rev
    // Ivan Alfaro
    -- Professional Web Developer

  12. #12
    Full Member Marshall is on a distinguished road
    Join Date
    May 2004
    Posts
    69
    i dont think u would want to totally ban their ip from ever submitting again, instead save a timestamp in the mysql database when they submit and whenever they try to submit again, compare timestamps and if its within 1 hour of the original timestamp do not allow them to send but if its after allow them to send. That removes the "1 time send only" problems that may arise.

  13. #13
    Active Member Revenant is on a distinguished road
    Join Date
    May 2004
    Location
    Chicago, IL US of A
    Posts
    108
    Doh, i forgot to mention, the ban'll be temporary.
    // Rev
    // Ivan Alfaro
    -- Professional Web Developer

  14. #14
    Full Member HellFear is on a distinguished road
    Join Date
    Jun 2004
    Posts
    69
    Thanks ! I hope this works, I've been searching for a contact form script because of spam bots..

  15. #15
    Newbie Cindy is on a distinguished road
    Join Date
    Jun 2004
    Location
    New York
    Posts
    3
    I used to use simple cgi contact forms written in perl on my web pages... wouldn't those pose the same risk as described above? Unfortunately spam and such has gotten to be a much bigger problem than it was years ago.

+ Reply to Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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