FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


problem with validation script





inphurno
Hi everyone,

i'm looking for a php script to go with my email form that will ask a user to enter in the text they see from an image. Also in my logs i saw that my validate.php has been executed, so someone has entered in an email or just pressed submit and then been taken to validate.php but i didnt get any email.

here is the code i use to verify if the email address is valid:

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

is it possible to add extra code that will log or even email me the info that was entered so i can see why i didn't get the email. some people might never return, so i want to log the data they entered, just in case the code didn't execute 100%.

hope you get what i mean and thanks in advance.
quasar
I do not understand PHP (I use Perl), but I can suggest the algorithm.

$ usr = "john" / / username

if (! preg_match ( "/ \ w +([-+.] \ w +) * @ \ w +([-.] \ w +) * \. \ w +([-.] \ w +)*/", from $) )
(
/ / Open log file (if it is not already open)
/ / Append user data (eg "User:" $ usr + white space + "Email:" + $from)
/ / Close log file
echo "Invalid email address, please check and try again <a href='javascript:history.back(1);'> Click here to return </ a> </ br>";
)
kv
create a table in the database to log all the submits (both failed and validated) with complete info.

use
Code:

mysql_query('Insert into <table name> values(...)');

to create entries in the database.

You can retrieve failed entries by something like this
Code:

mysql_query("select * from <table name> where status='failed' ");


use php mail function ( refer http://www.php.net/mail ) to send a mail to yourself.
rvec
instead of your preg replace try this: http://nl2.php.net/manual/en/function.filter-var.php
I think i'd be a lot easier Razz
inphurno
thanks for all your responses everyone, this helped a lot! i will give it a try and let you know...
Related topics
problem with a php randomizer script
How to get info about uploaded files while upload process
Script Problem
PM Logout
php
Javascript - Unexpected results
please please beta test it (PHP coders)
Modify a Reg keys
Session directory permissions issue
Email Validation script
Two validations process
How to resolve these URIs?
Simple Form Validation [solved]
Need Help on creating a validation script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.