Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    email/name in the "from" field?

    i hv a sign-up form, but when the contents are sent to me, the from field is always the server name of my webhost. is there a way to make it so that the email address or name of the person signing up appears as the from field in my inbox?

    also, is there a way to check whether the email address entered has a '@' (for validity)? i tried using indexOf syntax, but not working.

    oh, one more thing, i'm using an image as reset and submit buttons. the submit button works fine, but when i click on the reset button, it doesnt reset. instead, it just does what the submit button would do. i hv this:
    <input type="image" value="cancel" src="images/reset.jpg">
    is there something wrong?

    thanks.
    Last edited by loonatik; 03-18-2003 at 11:49 PM.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    $to 'their@emailaddress.com';
    $subject ='Your subject';
    $body 'Your message';
    $header 'Your email address <you@yourdomain.com>';

    mail($to,$subject,$body,$header); 
    this looks a decent email validation script (not checked, just glanced over), taken from http://php.net/eregi
    PHP Code:
    // function to validate email
    function validate_email($email_raw) {

    // replace any ' ' and \n in the email 
    $email_nr eregi_replace("\n"""$email_raw);
    $email eregi_replace(" +"""$email_nr);

    // do the ergei to look for bad characters
     
    if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*".
    "@([a-z0-9]+([\.-][a-z0-9]+))*$",$email) ){
    // okay not a good email
    $feedback "Error: $email isn't a valid mail address!";
    return 
    $feedback;
    } else {
    // okay now check the domain
    // split the email at the @ and check what's left
    $item explode("@"$email);
    $domain $item["1"];
    if( 
    gethostbyname($domain) == $domain) {
    $feedback "Error: $domain isn't a valid domain!";
    return 
    $feedback;
    } else {
    $feedback "valid";
    return 
    $feedback;
    }
    }



  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    For the button (nothing to do with php, but as it's mainly a php thread, I'll give you the answer)
    Code:
    <noscript>
    <p><input type="reset" value="Clear"></p>
    </noscript>
    
    <script type="text/javascript">
    <!--
    document.write('<p><a onclick="document.theform.reset();return false;"',
    'href="#"><img alt="Clear" src="clear.gif" border="0"><\/a><\/p>');
    //-->
    </script>
    Plenty of ways to do it on here

  • #4
    New Coder
    Join Date
    Mar 2003
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    one more question...

    everything works. thanks.

    one more question - can i also have the ip address of the person signing up to be sent to me also? i think it's environment variables in cgi/perl, but not sure about php.

    Thanks.

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    $REMOTE_ADDR

  • #6
    [m]
    [m] is offline
    New Coder
    Join Date
    Nov 2002
    Location
    Virginia, USA
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol I was going to post a topic on how to validate emails but I lookd through the topics first... this might solv my problem..I'm glad I looked here
    .:mike:.

    I'm a newbie

  • #7
    New Coder
    Join Date
    Jan 2003
    Location
    Tulsa, OK
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use e-mail headers for the mail function.

    $headers = "From: $name <$email>\r\n";

    By the way. On the 2nd post's example I dont think "Your email address" is a valid e-mail header.

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    What's the difference from what I put and what you've put?

    <edit> Ahh, yeah, forgot the From: bit, glad someone picked it up</edit>

  • #9
    New Coder
    Join Date
    Jan 2003
    Location
    Tulsa, OK
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The From: explicit, and the ending carriage returns '\r\n'

    Yes.

    Yog?


  •  

    Posting Permissions

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