Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

help contact form improvement

the mail() function

Moderators: macek, egami, gesf

help contact form improvement

Postby sebastianandrei » Mon Apr 01, 2013 2:27 am

Hello !

I am sure there is more than one smart guy around here that is awesome enough to figure out the solution for my challenge here.

So I have a contact form and events on my website that I promote via other people also (affiliates).

People come chose event, put name, email, telefon and promotional CODE (actually affiliate code) aff1, aff2 etc.

At this point the form sends out an email to me for each registration.

How can I make the form send out an email to the affiliate also when a user inserts his affiliate code in the CODE input box ?

So one mail comes to me and automaticly one goes to the affiliate.

I think at two different solutions - either with database or not.
A. database

In my database I have one colum with affiliate codes and next one with their email address. The form searches for a match in database for code entered and if finds a match it send a copy of form submission to the email address associated with the affiliate code it found.

B. using IF

IF input_affcode = 001 then sendmail to aff1@yahoo.com
IF input_affcode = 002 then send mail to aff2@gmail.com

etc.

Now I don't know how to do that in coding :) Please help me out.

For this moment I am using SIMFATIC forms 3.2 http://www.simfatic.com/ and I would like to have this small function implemented to the code....otherwise it works very well.

This is part from main code...my thought is to condition the autoresponder to send depending on the promo-code it finds in the input field.

[PHP]$data_email_sender = new FM_FormDataSender(sfm_readfile("./templ/contactus_email_subj.txt"),sfm_readfile("./templ/contactus_email_body.txt"),"%email_f%");
$data_email_sender->AddToAddr("office@universulsacru.ro");
$formmailobj->addModule($data_email_sender);

$autoresp = new FM_AutoResponseSender(sfm_readfile("./templ/LP_inregistrare_resp_subj.txt"),sfm_readfile("./templ/LP_inregistrare_resp_body.txt"));
$autoresp->SetToVariables("numeprenume_f","email_f");
$formmailobj->addModule($autoresp);[/PHP]


All the best to you!
Andrei Stefan
sebastianandrei
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Apr 01, 2013 2:16 am

Re: help contact form improvement

Postby developerahusain » Mon Jun 03, 2013 9:19 am

if ($_POST ['b_submit'])
{
$row1=mysql_fetch_array (mysql_query ("select from youraffliatetable where affliate_code='".$_POST ['aff_code']."'"));

$to =$row1 ['email'];
$subject ='Job Opportunity @ m`brace';
$message ='<head>
<title>Untitled Document</title>
<link href="../include/css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
your content
</body>
</html>
';
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From:'.$_POST['from']."\r\n";

mail($to,$subject,$message,$headers);
echo "<script language='javascript'>window.location='?do=msg1'</script>";
}
<body>
<form name='asdf' method="post">
<input type='text' name='aff_code'>
<input type="submit" name="b_submit">
</form>
</body>

This will work out for you. Any problem do revert to me as i have done lot of coding like this

Developerahusain
developerahusain
New php-forum User
New php-forum User
 
Posts: 44
Joined: Tue May 28, 2013 10:04 pm
Location: India,Lucknow


Return to PHP coding => Mail

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron