View Full Version : Simple Newsletter Form Help Please
Sunnah
07-31-2005, 02:01 AM
I have been having difficulty finding a way to make this form work. I only have two options- Add and Remove. I just want the requests "Add" or "Remove" , check box, associated email address sent, and validation on the null email address. Along with a confirmation page of "Thank you" if possible. Can some one please look at it? Thank you very much.
http://p.ssyed.com/masbs/v4/index.htm
-=Sunnah=-
Sunnah
07-31-2005, 02:39 AM
So far I have this script:
<SCRIPT LANGUAGE="php">
</SCRIPT>
<SCRIPT LANGUAGE="php"></SCRIPT>
</span>
<SCRIPT LANGUAGE="php">$email = $HTTP_POST_VARS[email];
$mailto = "not@thistime.com";
$mailsubj = "eNewsletter";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$mailbody .= "$key : $val\n"; }
mail($mailto, $mailsubj, $mailbody, $mailhead);
</SCRIPT>
I am getting this email output:
Values submitted from web site form:
email : not@thistime.com
addSub : Add
removeSub : Remove
subscribe_x : 32
subscribe_y : 16
subscribe : Submit
How can I get this form to give me some understandable output? And it seems when submitting the form it also requires that a local mail client on the local machine.
Sunnah
07-31-2005, 03:05 AM
Also my radio buttons are both being selected instead of one or the other.
My output:
Values submitted from web site form:
email : tsting@testinmg.com
Send_the_eNewsletter : Add
I_do_not_want_to_receive_the_eNewsletter_ : Remove
subscribe_x : 37
subscribe_y : 16
subscribe : Submit
Sunnah
07-31-2005, 10:44 AM
I updated the script and tried to modify the php. But I am not getting it to work exactly. I am still having the problm with both radio button selected. I thought I added the radio buttons and the checkbox correctly. I am always getting the error page.
My php:
$mailto = 'testing@testing.com' ;
$subject = "eNewsletter" ;
$formurl = "http://p.ssyed.com/masbs/v4/index.htm" ;
$errorurl = "http://p.ssyed.com/masbs/v4/error.htm" ;
$thankyouurl = "http://p.ssyed.com/masbs/v4/thankyou.htm" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$add = $_POST['add'] ;
$remove = $_POST['remove'] ;
$html = $_POST['html'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($add) || empty($remove)) {
header( "Location: $errorurl" );
exit ;
}
$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\r\nReply-To: \"$name\" <$email>\r\nX-Mailer: chfeedback.php 2.04" );
header( "Location: $thankyouurl" );
exit ;
Sunnah
07-31-2005, 05:24 PM
I have got the error page and the thank you page working. I got an email after I submitted it but it was blank.
-=Sunnah=-
Form:
<form action="eNewsletter.php" method="post" name="newsL" id="newsL">
<p>Enter your full name and email address in the boxes below to receive a notice each time we post a new issue of our Newsletter.</p>
<p>First & Last Name:
<input name="name" type="text" id="name" size="15" maxlength="100" />
</p>
<p>Email Address:
<input name="email" type="text" id="email" size="15" maxlength="100" />
</p>
<div>
<input type="radio" value="Add_Me" name="radio" checked="checked" />Add
<input type="radio" value="Remove_Me" name="radio" />Remove
</div>
<p>
<input type="checkbox" name="checkbox" value="Send_HTML" checked="checked" />
Send as HTML
</p>
<p>
<input name="subscribe" type="image" value="Submit" src="images/sub.gif" alt="Subscribe" />
</p>
</form>
<<====================================>>
PHP:
$subject = "eNewsletter" ;
$formurl = "index.htm" ;
$errorurl = "error.htm" ;
$thankyouurl = "thankyou.htm" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$radio = $_POST['add'] ;
$radio = $_POST['remove'] ;
$checkbox = $_POST['html'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email)) {
header( "Location: $errorurl" );
exit ;
}
$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
if (get_magic_quotes_gpc()) {
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\r\nReply-To: \"$name\" <$email>\r\nX-Mailer: chfeedback.php 2.04" );
header( "Location: $thankyouurl" );
exit ;
?>
_Aerospace_Eng_
07-31-2005, 05:36 PM
PM Scoutt, Pegasus, or Kemakalfire and ask them to move this for you to the server side php forum. Your problem might be stemming from this
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$radio = $_POST['add'] ;
$radio = $_POST['remove'] ;
$checkbox = $_POST['html'] ;
$http_referrer = getenv( "HTTP_REFERER" );
You are trying to post something that isn't referenced in the form the radio, which you have a value being posted not the name of the input, same goes for the check box.. Try this instead
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$radio = $_POST['radio'] ;
$checkbox = $_POST['checkbox'] ;
$http_referrer = getenv( "HTTP_REFERER" );
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.