954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please help with email form script

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:

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



Email:

full name:

message:
//that has to be able to take up to 4-5 lines of message(about 1000 characters)


=================================================
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"Home > $la_mod_cont_header
";

// 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 "


$la_mod_cont_email_inv";
$again=1;
}//end validate email
// ensure names have been entered
if (empty($from_name))
{
Echo "


$la_account_form_must";
$again=1;
}
// if user did not enter a message
if(empty($message))
{
Echo "


$la_mod_cont_mess_inv";
$again=1;
}
// display link if error occurred
if ($again==1)
{
echo"$la_mod_cont_corr


";

} // 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"$la_mod_cont_succ $to_email!


";
}
}//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"];
}
?>
<?echo $la_mod_cont_sub_header?>


<?echo $la_mod_cont_name?>
*
<?echo $la_mod_cont_addr?>
*
<?echo $la_mod_cont_department?>
Please Select Department
SalesTechnical SupportWebmasterAffiliates *
<?echo $la_mod_cont_subject?>
*

<?echo $la_mod_cont_mess?>
<?php echo $message; ?>

 

<?echo $la_account_form_must?>

<?
}//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

classifieds100
Newbie Poster
5 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

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?

barnamos
Junior Poster in Training
50 posts since Mar 2005
Reputation Points: 15
Solved Threads: 0
 

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.Add the info to your autoresponder system
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.
[php]
$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);
[/php]
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.

Troy
Posting Whiz
362 posts since Jun 2005
Reputation Points: 36
Solved Threads: 6
 

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

classifieds100
Newbie Poster
5 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You