Newsletter Submit Code
Moderator: General Moderators
Newsletter Submit Code
Hey, this is my first php coding attempt. I'm half way there. I'm setting up a Newsletter submit form on this site: http://www.ironworksmusic.com go to home page and click on newsletter. There are several fields that my client wants to obtain. Through tutuorials from several places, I've figured out how to at least get the email addresses registered and sent to myself, but I don't know how to tell the code to email me the name, age, etc of the other fields. Most tutorials and such are much more involved than i feel is required. If anyone could tell me directly what is lacking it would be a huge relief.
Here is the code that is my Newsletter.html:
</script>
<FORM METHOD=POST ACTION="sendmail.php">
<INPUT TYPE=HIDDEN NAME="to" VALUE="upscene@mac.com">
<INPUT TYPE=HIDDEN NAME="subject" VALUE="Ironworks Newsletter Signup">
<INPUT TYPE=HIDDEN NAME="submit" VALUE="http://www.ironworksmusic.com/thankyou.html">
Here is the code that is in my Sendmail.php:
<?
$email = $_REQUEST['email'] ;
mail( "upscene@mac.com", "Ironworks Newsletter Signup", "From: $email", "email: $email" );
header( "Location: http://www.ironworksmusic.com/thankyou.html" );
?>
thanks!
mel
Here is the code that is my Newsletter.html:
</script>
<FORM METHOD=POST ACTION="sendmail.php">
<INPUT TYPE=HIDDEN NAME="to" VALUE="upscene@mac.com">
<INPUT TYPE=HIDDEN NAME="subject" VALUE="Ironworks Newsletter Signup">
<INPUT TYPE=HIDDEN NAME="submit" VALUE="http://www.ironworksmusic.com/thankyou.html">
Here is the code that is in my Sendmail.php:
<?
$email = $_REQUEST['email'] ;
mail( "upscene@mac.com", "Ironworks Newsletter Signup", "From: $email", "email: $email" );
header( "Location: http://www.ironworksmusic.com/thankyou.html" );
?>
thanks!
mel
Code: Select all
// this should do the trick, but there are no security checks.
$name = $_POST['name'];
$email = $_POST['email'];
$state = $_POST['state'];
$age = $_POST['age'];
$comments = $_POST['comments'];
function send_mail($from, $to, $subject, $body) {
$header = "From: " . $from . "\n";
$mail_to = $to;
mail($mail_to, $subject, $body, $header);
}
$message = $name . " wants to be added to the email newsletter. " . $name . " is in " . $state . " and is " . $age . " years old.\n\n";
$message .= $name . " said, " . '"' . $comments . '"';
send_mail("From Name <blah@blah.com>", "To Name <blah@blah.com>\n", "Subject", $message);It's your:
Code: Select all
header( "Location: http://www.ironworksmusic.com/thankyou.html" );<?
$name = $_POST['name'];
$email = $_POST['email'];
$state = $_POST['state'];
$age = $_POST['age'];
$comments = $_POST['comments'];
function send_mail($from, $to, $subject, $body) {
$header = "From: " . $from . "\n";
$mail_to = $to;
mail($mail_to, $subject, $body, $header);
}
$message = $name . " wants to be added to the email newsletter. " . $name . " is in " . $state . " and is " . $age . " years old.\n\n";
$message .= $name . " said, " . '"' . $comments . '"';
send_mail("From Name <upscene@mac.com>", "To Name <upscene@mac.com>\n", "Subject", $message);
header( "Location: http://www.ironworksmusic.com/thankyou.html" );
?>
$name = $_POST['name'];
$email = $_POST['email'];
$state = $_POST['state'];
$age = $_POST['age'];
$comments = $_POST['comments'];
function send_mail($from, $to, $subject, $body) {
$header = "From: " . $from . "\n";
$mail_to = $to;
mail($mail_to, $subject, $body, $header);
}
$message = $name . " wants to be added to the email newsletter. " . $name . " is in " . $state . " and is " . $age . " years old.\n\n";
$message .= $name . " said, " . '"' . $comments . '"';
send_mail("From Name <upscene@mac.com>", "To Name <upscene@mac.com>\n", "Subject", $message);
header( "Location: http://www.ironworksmusic.com/thankyou.html" );
?>
You do realize that you have to put tags before and after the code....
ie
ie
Code: Select all
<?php
// all the code goes here.....
?>