Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 10 1 2 3 ... LastLast
Results 1 to 10 of 97
  1. #1
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    If you're like me then you never want to give out your real e-mail address. As a result you'll never (literally) get spam.

    Here's a form similar to the one I use (click Contact at the top of the page to see it in action):

    PHP Code:
    <?
    require('header.php');

    if (isset(
    $_POST['from']))
    {
        
    $ip $_SERVER['REMOTE_ADDR'];
        
    $resolved gethostbyaddr($ip);
        if (
    $resolved != $ip)
        {
            
    $footer "This e-mail was sent by a user with the IP address $ip, which resolved to '$resolved'.";
        }
        else
        {
            
    $footer "This e-mail was sent by a user with the IP address $ip, which could not be resolved to a hostname.";
        }
        
    $message $_POST['message'];
        
    $message "$message\n\n------------\n$footer";
        
        if (
    mail('[b][i]YOUR E-MAIL ADDRESS[/i][/b]'$subject$message"From: $from\r\nReply-To: $from\r\n"))
        {
            echo 
    'Your mail was successfully sent.';
        }
        else
        {
            echo 
    'There was an error while sending the mail.';
        }
    }
    else
    {
    ?><form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
      <p>Please be aware that your IP address (<? echo $_SERVER['REMOTE_ADDR'?>) will be sent along with the message 
        to prevent against abuse of this mail form.</p>
      <table border="0" cellspacing="0" cellpadding="3">
        <tr> 
          <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Your 
            e-mail address:</font></b><i><font face="Trebuchet MS, Verdana, Tahoma, Arial, sans-serif" size="1"><br>
            <input type="text" name="from" size="60">
            </font></i></td>
        </tr>
        <tr> 
          <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Subject:</font></b>
          <i><font face="Trebuchet MS, Verdana, Tahoma, Arial, sans-serif" size="1"><br>
            <input type="text" name="subject" size="60">
            </font></i></td>
        </tr>
        <tr> 
          <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><a href="/forums/">Forums</a> 
            Username:</font></b><br>
            <i><font face="Trebuchet MS, Verdana, Tahoma, Arial, sans-serif" size="1">Leave 
            this field blank if you are not registered.<br>
            <input type="text" name="forumsusername" size="60">
            </font></i></td>
        </tr>
        <tr> 
          <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Message:<br>
            <textarea name="message" rows="10" cols="60"></textarea>
            </b></font></td>
        </tr>
        <tr>
          <td align="right"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Click 
            &quot;Send&quot; only once.</font><br>
            <input type="submit" value="Send">
          </td>
        </tr>
      </table>
    </form>
    <?
    }

    require(
    'footer.php');
    ?>
    If you are not using a templated site or don't know what one is, remove the lines require('header.php') and require('footer.php') and just put this entire chunk of code where you want the form to appear in your page.

    When the user sends an e-mail to you, they never see your e-mail address. You see something like:

    Message here
    ----------
    This e-mail was sent by a user with the IP address 12.34.56.78, which resolved to 'hostname.isp.com'
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  2.  

  3. #2
    Senior Member
    Join Date
    Oct 2002
    Location
    Nashville, Tennessee
    Posts
    133
    Member #
    233
    E-mail form help!

    Hello all!

    Filburt was kind enough to put up the PHP tutorial for me to be able to make an e-mail form for my site that wouldn't prompt the user before sending the information, for which I'm VERY grateful!

    Since I have absolutely NO experience with PHP, I'm having a little problem with the form. I've pretty much tried to hack the code out to get it customized for my form, but when I try to actually click 'Send', I get the following error:

    Warning: mail() expects at most 5 parameters, 6 given in /home/yuyusist/public_html/agentform.php on line 30
    There was an error while sending the mail.

    How can I get that fixed so that it'll accept all the variables I have there on that line?

    Thanks!

  4. #3
    Senior Member
    Join Date
    Oct 2002
    Location
    Nashville, Tennessee
    Posts
    133
    Member #
    233
    Oops....

    Here's the URL to it....forgot about that!

    http://www.yuyusisterhood.com/agentform.php

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Hmm...copy and paste the line you put in your script here that looks similar to this one: if (mail('YOUR E-MAIL ADDRESS', $subject, $message, "From: $from\r\nReply-To: $from\r\n")) (i.e., post what your line looks like)
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Senior Member
    Join Date
    Oct 2002
    Location
    Nashville, Tennessee
    Posts
    133
    Member #
    233
    Here it is:

    if (mail('Your name', $from, $company, $phone, $charity, "From: $mail\r\nReply-To: $mail\r\n"))

    I realize I've got 5 different variables in there, but is that all necessary for the mail go to through?

    Thanks again!

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    That would explain it.

    Try:
    PHP Code:
    if (mail('your (hanznsolo) e-mail address'$subject,
        
    "$message\n\nCompany: $company\n$Phone$phone\nCharity: $charity",
        
    "From: $mail\r\nReply-To: $mail\r\n")) 
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    Senior Member
    Join Date
    Oct 2002
    Location
    Nashville, Tennessee
    Posts
    133
    Member #
    233
    Okay, I'm gonna try that now...but what about the (hanznsolo) part? That name has nothing to do with the actual site, so can that be omitted from the line?

  9. #8
    Senior Member
    Join Date
    Oct 2002
    Location
    Nashville, Tennessee
    Posts
    133
    Member #
    233
    Well, I tried it. Now, I'm getting the less specific 'there was an error in generating the mail' message....now what?

  10. #9
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Replace your (hanznsolo) e-mail address with your actual e-mail address.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  11. #10
    Senior Member
    Join Date
    Oct 2002
    Location
    Nashville, Tennessee
    Posts
    133
    Member #
    233
    Cool, thanks! As soon as the stupid server comes back up (it just went down), I'll check it out.

    Now, if I can just get this STUPID menu centered....

    http://www.yuyusisterhood.com/menu2.html

    Do you happen to have any ideas on that one?


Page 1 of 10 1 2 3 ... LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:27 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com