Web Hosting Talk







View Full Version : Please help with email form script


classifieds100
05-31-2005, 04:19 PM
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=htt_p://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

RobertMaltby
06-04-2005, 11:18 AM
Heres what i use...

On the Form Page:

<form name="quickemail" method="POST" action="sendemail.php">

<input type="text" name="name" size="23" value="Name" onFocus="clearText(this)"></input>

<input type="text" name="email" size="23" value="Email Address" onFocus="clearText(this)"></input>

<textarea name="comments" rows=4 cols=17 onFocus="clearText(this)">Message</textarea>

<input type=submit VALUE="Send Mail"></input>

</form>


Then my sendemail.php page:


<?php

$myemail = "Support@Profound-Hosting.com";
$visitor = $_POST['name'];
$visitormail = $_POST['email'];
$notes = $_POST['comments'];
$subject = "Profound-Hosting.com Quick Contact Form";
$todayis = date("l, F j, Y, g:i a") ;

if ($visitormail == "" | $visitor == "" | $notes == "")
{

include ("includes/formvalidate.inc");

die();
}


$message = "
Profound Hosting Quick Contact Form\n
From:\n $visitor ($visitormail)\n
Message:\n $notes
";

$from = "From: $visitormail\r\n";

if ($myemail != "")
mail($myemail, $subject, $message, $from);

?>

<? include ("includes/header.inc") ?>
<br><center>

<?php echo $visitor ?> ( <?php echo $visitormail ?> ) , Thanks for contacting Profound Hosting, we will reply shortly.
<br><br>
<a href="http://www.Profound-Hosting.com">Click Here</a> to return to Main Page

<? include ("includes/footer.inc") ?>



With a little more modification im sure you can have the form email your vistor... (Right now it only emails you the information)

Good Luck.