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. 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
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>"; } ?>
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.
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
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.
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
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
The link is dead... .....No it's not I changed the CA to ES and it works... es for Spain, where I am.
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
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