Welcome to WebmasterWorld Guest from 23.20.241.155

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Add email to Hsphere Mailing List?

how do i do it via php?

     
8:14 am on Aug 25, 2004 (gmt 0)

10+ Year Member



Hi there i am coding page for a friend and i am a total newbie at this so i need some help!
I am wanting to add the visitors email to a hsphere mailing list with an address of list-subscribe@email.com
The problem i am finding is that this page is getting a little to complex for me as i have cut and paste code from all over the net to help me!

The form takes peoples details and does a few things.

1. It sends the details that are filled in to the website administrator

2. it sends the user a confirmation email that they have succesfully registered for the competition and

3. I want it to add the email that is punched in to a mailing list?!?!?

I have tried just using another
mail("$email", "yada", "yada"}
function but i cant get it right! I keep getting errors and such.
Am i on the wrong track here? Can somebody help me with this as it is doing my head in!

Also when i recieve the email in Microsoft Outlook all i see is the code whereas if i open it in outlook express or yahoo mail or whatever it is nicely formatted any ideas on what could be causing this?

Any help would be much appreciated.

Thanks Alot
Enrico

<?
// THIS IS THE BEGINNING OF THE PHP CODE
$clubname = @$HTTP_POST_VARS['clubname'];
$clubaddress = @$HTTP_POST_VARS['clubaddress'];
$clubaddressb = @$HTTP_POST_VARS['clubaddressb'];
$seniors = @$HTTP_POST_VARS['seniors'];
$juniors = @$HTTP_POST_VARS['juniors'];
$role = @$HTTP_POST_VARS['role'];
$name = @$HTTP_POST_VARS['name'];
$state = @$HTTP_POST_VARS['state'];
$city = @$HTTP_POST_VARS['city'];
$phone = @$HTTP_POST_VARS['phone'];
$email = @$HTTP_POST_VARS['email'];
$role = @$HTTP_POST_VARS['role'];
$error_msg="";
$msg="";

function NumGen($length)
{
for ($i = 1; $i <= $length; $i++)
{
if ($i == 1)
$randnum = rand(0, 9);
else
$randnum .= rand(0, 9);
}

return $randnum;
}

$entrynumber = NumGen(10);

if(!$name){
$error_msg .= "<p class=mf>Your name \n";
}
if($name){
$msg .= "Your Name: \t $name \n";
}
if(!$phone){
$error_msg .= "<p class=mf>Your phone number \n";
}
if($phone){
$msg .= "Phone: \t $phone \n";
}
if(!$email){
$error_msg .= "<p class=mf>Your email\n";
}
if($email){
if(!eregi("^[a-z0-9._]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){
echo '<p class=mf>That is not a valid email address. Please<a href="javascript:history.back()"> return </a> to the previous page and try again.';
exit;
}
$msg .= "Email: \t $email \n";
}

if(!$clubname){
$error_msg .= "<p class=mf>Your Club's Name \n";
}
if($clubname){
$msg .= "Club Name: \t $clubname \n";
}

if(!$clubaddress){
$error_msg .= "<p class=mf>Your Club's address \n";
}
if($clubaddress){
$msg .= "Club Address: \t $clubaddress \n";
}

if(!$city){
$error_msg .= "<p class=mf>Your Club's City \n";
}
if($city){
$msg .= "City: \t $city \n";
}

if(!$state){
$error_msg .= "<p class=mf>Your Club's State \n";
}
if($state){
$msg .= "State: \t $state \n";
}

if($seniors){
$msg .= "Senior Teams: \t $seniors \n";
}

if($juniors){
$msg .= "Juniors Teams: \t $juniors \n";
}

if(!$role){
$error_msg .= "<p class=mf>Your Role \n";
}
if($role){
$msg .= "Role: \t $role \n";
}

$sender_email="";

if(!isset($name)){
if($name==""){
$sender_name="Web Customer";
}
}else{
$sender_name=$name;
}
if(!isset($email)){
if($email==""){
$sender_email="Customer@website.com";
}
}else{
$sender_email=$email;
}
if($error_msg!= ""){
echo"<br><p class=mf><font face=arial size=small color=#666666><strong>You didn't fill in these required fields:</font><br>"
. nl2br($error_msg) .'<br>Please <a href="javascript:history.back()"> return </a> to the'
." previous page and try again.";
exit;}
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "From: $sender_name <$sender_email>\r\n";
$mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n";
mail("me@example.com","Club Details",stripslashes($msg), $mailheaders);
echo " <br><h2>Thank you for your feedback $name</h2>";
echo '<p class=mf><b>This is the information you submitted</b><br><br>';
echo nl2br(stripslashes($msg));echo '</p>';
echo ' <p class=mf><font face=arial size=small color=#666666><strong>You will recieve an email shortly!</strong></font><br>
If the information you see here is incorrect please <a href="http://www.example.com/sports_landing.php">return</a> to the previous page and try again.<br><br>
<font face=arial size=small color=#666666><strong>Want to know more about Design IMPORTance?</font></strong><br>
<a href="http://www.example.com">Click here</a> to view the Design IMPORTance website.
<br><br>';

/* recipients */
$to = "" . ", " ; // note the comma
$to .= "$email";

/* subject */
$subject = "Welcome to example";

/* message */
$message = '
<html>
<head>
<title>Email</title>
<snip>styles snipped</snip>
</head>

<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<snip>html snipped, url cut</snip>
<td><div align="center">
<p><strong><span class="style27"><span class="style31">CONGRATULATIONS &amp; GOOD LUCK </p>
</td></tr></table>
</body>
</html>

';

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "To: SOandSO <j@email.com>\r\n";
$headers .= "From: SOandSO <j@email.com>\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);

//THIS IS THE END OF THE PHP CODE?>

[edited by: jatar_k at 5:07 pm (utc) on Aug. 25, 2004]
[edit reason] excess html and css snipped [/edit]

5:16 pm on Aug 25, 2004 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



>> in Microsoft Outlook all i see is the code

if it works in others it seems the settings in outlook may not like html emails

>> I keep getting errors and such.

what are the errors?

To be added to this mailing list do they need to be in a db or do you actually need to send an extra email? You could just add a Cc: to another address if that would do.

7:45 pm on Aug 25, 2004 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It may be choking on the "\r\n". Maybe just a "\n" is necessary?
3:42 am on Aug 26, 2004 (gmt 0)

10+ Year Member



Hi there Guys and thanks for replying.

In regards to outlook i recieve other html emails that are fine so it says to me its something about this particular email probably the code somewhere?

And in regards to the mailing list i have not had to much experience with mailing lists so i dont know wether its a database or not its sitting on the hosting acct. under the mailing list option and it has three addresses sports@yadayada.com sports-subscribe@yadayada.com and sports-unsubscribe@yadayada.com so if you sent an email to say Sports-subscribe@yadayada.com wouldnt it add the email to the list?

If so does anyone know any simple code for this?

Thanks again for your help its much appreciated.

Enrico

 

Featured Threads

Hot Threads This Week

Hot Threads This Month