Hey all,
I am offering users at my blog site a 'mailing list' feature for them to be able to send newsletters to all their subscribers.
In addition to having a textbox on their blog homepage for people to subscribe, I am allowing the blog owner, in their member control panel, to add up to 10 email addresses manually.
On my form for them to add the email addresses manually, I have 20 textboxes. 10 for email addresses, and 10 for their respective names. (I store an email address with a name attached to it to make it easier for the owner of the blog).
In order for an email address to be added to the database, it has to pass through the following validate_email function:
function validate_email($str)
{
$str = strtolower($str);
if(ereg("^([^[:space:]]+)@(.+)\.(ad|ae|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|fi|fj|fk|fm|fo|fr|fx|ga|gb|gov|gd|ge|gf|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nato|nc|ne|net|biz|info|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$",$str))
{
return true;
}
else
{
return false;
}
}
So my question is this: if all but one of the ten e-mail addresses entered into the form passes this validate email test, they will be forced to fix it. So I will return them to the form with the 20 textboxes for them to fix it...but I am going to have to return all the data back to the form (it would SUCK for the member to have to re-input everything for one error in format).
What is the best way to return the data back to the form, if I am using the POST method for the form?
Would it be doing something like this:
//error in email address 9
header('Location: mail_list_add_emails.php?em1=good@email.com&name1=idiot&em2=good@emai.com&name2=face&em3=good@email.com&n3=fruit&em4=good@email.com&n4=cake&so_on&so_on');
exit;
There has to be a better way of doing this?