Page 1 of 1

contact address

Posted: Tue Oct 23, 2007 3:48 am
by shivam0101
I have a form in which the clients will add his email id, to email id and message and send the form.

The to email id will be added from contact address from his ids (yahoo, gmail etc)


1. I want the clients to export their address form their accounts and in my form i am reading that file and generate checkboxes against each email ids where they check and submit.

For yahoo and gmail, it worked fine. But i am not able to do the same for msn.

Below is the code for yahoo and gmail,

Code: Select all

$file_tmp=file($_FILES['file']['tmp_name']);
	$domain=$_POST['domain'];

	if($domain=='gmail')
	{
       $table="<form method='post' action='contact.php?process=submit'><table border=1 width='20%' align='center'>";
       foreach($file_tmp as $file_tmp)
       {
	     $exp=explode(',', $file_tmp);
	     if($exp[0] !='Name' && $exp[1] !='E-mail')
	     $table.="<tr><td> $exp[0] </td> <td> $exp[1] </td> <td><input type='checkbox' name=email_id[] value=$exp[1]></td></tr>";
       }
 	   echo $table.="<tr><td align='center' colspan='3'><input type='submit' name='submit' value='submit'></td></tr></table> </form>";
   }
   
   elseif($domain=='yahoo')
   {
       $table="<form method='post' action='contact.php?process=submit'><table border=1 width='20%' align='center'>";
       foreach($file_tmp as $file_tmp)
       {
	     $exp=explode(',', $file_tmp);
		 $first_name=ereg_replace('"', "", $exp[0]);		 $middle_name=ereg_replace('"', "", $exp[1]);
		 $last_name=ereg_replace('"', "", $exp[2]);		     $email_id=ereg_replace('"', "", $exp[4]);
		 
		 if($first_name !='First' && $middle_name !='Middle' && $last_name !='Last' && $email_id !='Email')
	     $table.="<tr><td> $first_name $middle_name $last_name </td> <td> $email_id </td> <td><input type='checkbox' name=email_id[] value=$email_id></td></tr>";
       }
 	   echo $table.="<tr><td align='center' colspan='3'><input type='submit' name='submit' value='submit'></td></tr></table> </form>";
   }

Posted: Tue Oct 23, 2007 5:05 am
by shivam0101
Its solved, i have another problem now.

How to differentiate between the files, clients choose. They may choose file exported from gmail and select yahoo from drop down.

Posted: Tue Oct 23, 2007 6:41 am
by shivam0101
is it possible to write a single function to handle gmail, yahoo etc...?

is there any way where i can use

Code: Select all

fgetcsv
with

Code: Select all

file
. that is, i want to use

Code: Select all

fgetcsv
without uploading the file

Posted: Tue Oct 23, 2007 11:33 am
by feyd
It's not possible to read a file on a client without the client uploading it.

Posted: Wed Oct 24, 2007 12:26 am
by shivam0101
Thanks. But, how to differentiate between the files clients choose? They may choose file exported from gmail and select yahoo from drop down.

Posted: Wed Oct 24, 2007 9:44 am
by onion2k
shivam0101 wrote:Thanks. But, how to differentiate between the files clients choose? They may choose file exported from gmail and select yahoo from drop down.
You can't. You can validate the incoming data though, checking that there are the right number of fields, checking that what should be an email address matches the format of an email address, etc.