contact address

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

contact address

Post 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>";
   }
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post 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.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's not possible to read a file on a client without the client uploading it.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
Post Reply