Hi,

Can someone please help? I want to be able when I receive an email from my site's form
in the same time to add the visitor in my autoresponder software. I think I must have one more form (script)
to get the data from my php form and send them to my autorespond software that is creating
this form automaticaly:

================================================


<form method=post action=http://www.mysite.com/mail/signup.php>
<input type=hidden name=list value=1>
Email: <input type=text name=email><br>
full name: <input type=text name=user1><br>
message: <input type=text name=user2><br>  //that has to be able to take up to 4-5 lines of message(about 1000 characters)
<input type=submit name=sup value="Subscribe Me!">
</form>



=================================================

Below is the php email form from my cart:

<?php


session_start();
include("admin/config.php");
include( "admin/settings.inc.php");
include( "shoppingcart.php");
include( "header.inc.php");
$cart = new Cart;


include("subheader.inc.php");


// start border
sb("100%","$la_mod_cont_header",$colour_1,$colour_2);


// navigation
echo"<a href=\"store.php\" target=\"_self\">Home</a> > $la_mod_cont_header<br>";


// if contact form has been submit
if($submit){
// validate senders email
if ((!ereg("^[a-zA-Z0-9_.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $from_email))or(empty($from_email)))
{
Echo "<p><div align='center'><font color=#990000><b>$la_mod_cont_email_inv</b></font></p>";
$again=1;
}//end validate email
// ensure names have been entered
if (empty($from_name))
{
Echo "<p><div align='center'><font color=#990000><b> $la_account_form_must</b></font></p>";
$again=1;
}
// if user did not enter a message
if(empty($message))
{
Echo "<p><div align='center'><font color=#990000><b>$la_mod_cont_mess_inv</b></font></p>";
$again=1;
}
// display link if error occurred
if ($again==1)
{
echo"<p align=\"center\"><a href = \"contact_us.php?session=$session\">$la_mod_cont_corr</a></p>";


} // end ($again==1)
// build message
if(empty($again)){


$subject = "$la_mod_cont_Mfrom: $from_name";
$messagebody .="$la_mod_cont_Msend $site_url.\r\n\r\n";
$messagebody .="$la_mod_cont_Mwho $from_name $la_mod_cont_Mmail $from_email.\r\n\r\n\r\n";
$message = stripslashes($message);
$messagebody .="$message";
// send mail
mail($to_email, $subject_email, $messagebody, "From: $from_email");



// confirmation message
echo"<p align=\"center\">$la_mod_cont_succ <b>$to_email</b>!</p>";
}
}//end if submit


// display tell a friend form
if(!$submit){
if(session_is_registered(valid_user))
{
$select = mysql_query ("select * from ".$prefix."store_customer where email='$valid_user'");
$row = mysql_fetch_array($select);
$from_name=$row["name"];
$from_email=$row["email"];
}
?>
<p align="left"><?echo $la_mod_cont_sub_header?></p><br>
<script language="JavaScript">
<!--


var ns6=document.getElementById&amp;&amp;!document.all


function restrictinput(maxlength,e,placeholder){
if (window.event&amp;&amp;event.srcElement.value.length>=maxlength)
return false
else if (e.target&amp;&amp;e.target==eval(placeholder)&amp;&amp;e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}


function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&amp;&amp;e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}



function displaylimit(theform,thelimit){
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> <?echo $la_mod_cont_char?> '
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}
-->
</script>
<form name="form" action="contact_us.php?session=$session" method="post" >
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150" align="left"><strong><?echo $la_mod_cont_name?></strong></td>
<td><input name="from_name" value="<?php echo $from_name; ?>" type="text" class="textbox" size="30" maxlength="30"><font color="#990000"> *</font></td>
</tr>
<tr>
<td width="150" align="left"><strong><?echo $la_mod_cont_addr?></strong></td>
<td><input name="from_email" value="<?php echo $from_email; ?>" type="text" class="textbox" size="30" maxlength="30"><font color="#990000"> *</font></td>
</tr>
<tr>
<td width="150" align="left"><strong><?echo $la_mod_cont_department?></strong></td>
<td><select name="to_email" value="<?php echo $to_email; ?>">
<option selected value="Please Select Department">Please Select Department
</option>
<option value="test1@test.com">Sales</option>
<option value="test2@test.com">Technical Support</option>
<option value="test3@test.com">Webmaster</option>
<option value="test4@test.com">Affiliates</option>
</select><font color="#990000"> *</font></td>
</tr>
<td width="150" align="left"><strong><?echo $la_mod_cont_subject?></strong></td>
<td><input name="subject_email" value="<?php echo $subject_email; ?>" type="text" class="textbox" size="30" maxlength="30"><font color="#990000"> *</font></td>
</tr>
<tr>
<td align="left" valign="top"><strong><?echo $la_mod_cont_mess?></strong></td>
<td valign="top"><textarea name="message" cols="54" rows="10" id="message"><?php echo $message; ?></textarea><br><script language="javascript">displaylimit("document.form.message",1024)</script>
</td>
</tr>
<tr>
<td width="150" align="left" valign="top">&nbsp;</td>
<td><input type="submit" name="submit" class="submit" value="<?echo $la_mod_cont_send?>"><br> <?echo $la_account_form_must?></td>
</tr>
</table>
</form>
<?
}//end if no submit


// end border
eb($bg_colour,$colour_1);


include("subfooter.inc.php");
include("footer.inc.php");

Thanks for your time and help in advance

James

Edited 3 Years Ago by happygeek: fixed formatting

yikes thats a lot of code!

Does the autoresponder have a database on its back end? Can't you just poke it into the database yourself?

I'm not 100% clear what you want to do, but if I'm correct, you have a form where user data will be submitted. When it is submitted, you want to do two things with that data.

  1. Add the info to your autoresponder system
  2. Send an email with the data

Normally, I'd say, just code the functionality of both in one script. That is, do what ever code you need to add the info to your autoresponder, then do your code to send the email. Sounds simple.

However, since you are asking this question, my assumption is that you are using other people's scripts to do both functions. That is, you really don't know how to turn the two scripts into one script, so in your mind, you need a way to submit the form data to both functions. (hope I'm correct)

I do believe the most straightforward way to handle this is to create a single script that incorporate the functionality of both the current scripts. But, if that is NOT an option (I don't know your exact requirements), you can use curl in PHP to do a server-side call to another page.

$postdata = 'name='.$name;
$postdata .= '&age='.$age;
$postdata .='&email='.$email_address;

$ch=curl_init(); 

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_URL,"http://www.mydomain.com/somescript.php"); 
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$postdata); 

//Start ob to prevent curl_exec from displaying stuff. 
ob_start(); 
curl_exec($ch);

//Get contents of output buffer 
$res = ob_get_contents(); 

curl_close($ch);

Now, it is important that you make the curl call BEFORE you output anything. Start your normal browser output after you do the curl thing.
PHP Documentation for curl functions

If this does not make any sense to you, please post again with specific and minimal details to explain your issue. Thanks.

Hello,

Yes barnamos my autoresponder have a database on its back end.
And also thanks Troy for the reply. Yes this is exactly what I want to do.

I want to be able from my site to receive email from the form that is included in my shopping cart but I also want the same data, or minimum the name and email, fields to be submited to my autoresponder php software so my site visitor will get some followup emails later.

So yes, I need to turn the two scripts into one script.

How can I use this code in my shopping cart without messing things up with the other scripts on my site?

Regards

James

This article has been dead for over six months. Start a new discussion instead.