1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Enter code from image and other PHP question..

Discussion in 'PHP' started by ian_ok, Nov 16, 2004.

  1. #1
    Hi all,

    1. I'm looking for some php code to go with my exchange links email form that will ask a user to enter in the text they see from an image - to stop auto complete software from bombarding me....

    2. In my web logs I've noticed my confirmation.php has been displayed...i.e. someone has entered in an email address or just pressed submit and then been taken to confirmation.php but I've not recived any email.
    SEMrush
    Is it possible to add extra code that will log or even email the data to me that was entered in (if any) so I can see why I didn't get an email.

    My code I use to verify if the email is in the correct formation is:

    if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from))
    {
    echo "<h4>Invalid email address, please check and try again<a href='javascript:history.back(1);'> Click here to return</a></h4>";
    echo "<h4></h4>";
    }

    Of course people might never return, so I want to log the data they entered, just in case the code didn't execute 100%.

    Hope you can get what i am after.

    Ian
     
    ian_ok, Nov 16, 2004 IP
    SEMrush
  2. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    For some reason I don't have the edit mode available for this thread, so he is my amended question..

    I want to copy the email address to another varible and send it to me if the email address was entered in wrong and then ask the user to return to correct the data.

    WHY I hear you say...Well I've seen many logs of this php file yet no emails!!!

    This is my code:
    <?php
    $email = 'myemail@mywebsite.com';
    $subject = $HTTP_POST_VARS['subject'];
    $from = $HTTP_POST_VARS['from'];


    if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from))

    {
    echo "<h4>Invalid email address, please check and try again<a href='javascript:history.back(1);'> Click here to return</a></h4>";
    echo "<h4></h4>";
    }
    elseif(mail($email,$subject,$from,$test))
    {
    echo "<h4>$from has been added to our mailing list thank you.</h4>";
    echo "<h4></h4>";
    }
    else
    {
    echo "<h4>Sorry there is a problem, please send your request to: </h4>";
    echo "<h4></h4>";
    }
    ?>
     
    ian_ok, Nov 17, 2004 IP
  3. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Here is the validation code I use
    $validemailexpr="^[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$%&_-])*" ."@[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$%&_-])*$";
    	if (!eregi($validemailexpr,$from))
    PHP:
    This code also checks if the part following the "@" is a exsisting doman name.
     
    mushroom, Nov 17, 2004 IP
  4. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sorry I think I've made a mess of this thread......

    TO CONFIRM:

    I have no problem in validating the email address, what I want, is should the email address be invalid I want that INCORRECT EMAIL ADDRESS to be mailed to me and then still ask the user to return and complete correctly.

    WHY....Well I've seen many logs of this confirmation php file yet no emails!!!

    Ian
     
    ian_ok, Nov 18, 2004 IP
  5. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I do not see a value for $test, this being the 4th field in mail(); should contain all the header info, and with out it mail(); will not work correctly.
     
    mushroom, Nov 18, 2004 IP
  6. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yes sorry, my mistake the $test was done for me testing and I didn't remove it from the elseif command....

    Any help on what I want?

    Ian
     
    ian_ok, Nov 19, 2004 IP
  7. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Mail must have 4 fields in the form mail(to,subject,message,from);
    Here is the kind of format you need for the from part
    $from="Return-path: <postmaster@____.com>\r\nSender: <postmaster@____.com>\r\nFrom: <postmaster@_____.com>\r\nReply-to: <postmaster@_______.com>";
    PHP:
    Replace the "postmaster" and "____.com" with you address.
    Other things can go in there also see http://ca.php.net/manual/en/ref.mail.php
     
    mushroom, Nov 19, 2004 IP
  8. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The link is dead...

    .....No it's not I changed the CA to ES and it works...

    es for Spain, where I am.
     
    ian_ok, Nov 21, 2004 IP
  9. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hello Ian,

    --------------------------- For question 1
    Here's an article on Zend.com that discusses/shows in great detail how to protect against auto-submissions using images:

    http://www.zend.com/zend/tut/tutorial-mehmet1.php?article=tutorial-mehmet1&id=4635&open=1&anc=0&view=1

    And if you're curious, here's more informaiton about Captcha images:
    http://www.captcha.net/


    --------------------------- For question 2
    If I'm understanding you correctly then this will work.

    Insert a line that emails you what they entered for an email address when validation fails.

    {
    mail ( "yourEmailAddress, "Email Validation Failed", "Email validation failed for: $from", "From: yourEmailAddress\r \n" );

    echo "<h4>Invalid email address, please check and try again<a href='javascript:history.back(1);'> Click here to return</a></h4>";
    echo "<h4></h4>";
    }


    - Bert
    http://www.tropicrentals.com
     
    rvarcher, Dec 6, 2004 IP
  10. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks for that Bert,

    Yes spot on answered both questions...am doing a web-upgrade so in the new year I HOPE(!) to incorporate.

    Ian
     
    ian_ok, Dec 7, 2004 IP