Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check box value not seen in email

Status
Not open for further replies.

rastaIT34

Technical User
Sep 9, 2009
103
US
i cant get the code to email me that the user has checked the mailing list check box....

help please....




Code:
<?php 
$your_email ='rscr@rossow-web.com';// <<=== update to your email address

session_start();
$errors = ';
$name = ';
$mailinglist = ';
$visitor_email = ';
$user_message = ';

if(isset($_POST['submitButton']))
{
	
	$name = $_POST['name'];
	$mailinglist = $_POST['mailinglist'];
	$visitor_email = $_POST['email'];
	$user_message = $_POST['message'];
	
	///------------Do Validations-------------
	if(empty($name)||empty($visitor_email))
	{
		$errors .= "\n Name and Email are required fields. ";	
	}
	if(IsInjected($visitor_email))
	{
		$errors .= "\n Bad email value!";
	}
	if(empty($_SESSION['6_letters_code'] ) ||
	  strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
	{
	//Note: the captcha code is compared case insensitively.
	//if you want case sensitive match, update the check above to
	// strcmp()
		$errors .= "\n Security code does not match!";
	}
	
	if(empty($errors))
	{
		//send the email
		$to = $your_email;
		$subject="A visitor to [URL unfurl="true"]www.anneleone.com[/URL] has sent you a message. See below.";
		$from = $your_email;
		$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ';
		
		$body = "A user  $name submitted the contact form:\n".
		
		"Name: $name\n".
		"Mailing List: $mailing_list\n".
		"Email: $visitor_email \n".
		"Message: \n ".
		"$user_message\n".
		"IP: $ip\n";	
		
		$headers = "From: $from \r\n";
		$headers .= "Reply-To: $visitor_email \r\n";
		
		mail($to, $subject, $body,$headers);
		
		header('Location: contact_sent.html');
	}
}

// Function to validate against any email injection attempts
function IsInjected($str)
{
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="description" content="T "/>


<title> | ARTWORK</title>

<link href="css/global_style.css" rel="stylesheet" type="text/css" />
<link href="css/contactform.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/font_stylesheet.css" type="text/css" charset="utf-8" />


<script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>



</head>

<body>

<div id="container">

  
   <div id="header">   
  <center><a href="index.html"><img src="images/title.jpg" width="502" height="82" alt="Anne Leone_title" border="0" /></a>
  </center></div>




<div id="navbckgrnd">

	<div id="nav_menucontainer">
<ul id="navmenu">
            <li><a href="paintings.html" >Paintings</a></li>
            <li><a href="bio.html" >Biography</a></li>
            <li><a href="contact.html" >Contact</a></li>
        </ul>
	</div>
     
</div>



<div id="sitemap"><a href="index.html">home</a> | contact</div>

<br />

<div id="formwrap">

<form name="contact_form"  action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">

<fieldset>

<div class="row"><label for='name' class="col1">Full Name:&nbsp;&nbsp;</label>
  <span class="col2">

  <input name="name" class="input" type="text" id="name" size="20" tabindex="1" style="font-size:17px;"  />
  </span></div>


  <div class="row"><label class="col1">Mailing List:&nbsp;&nbsp;</label>
  <span class="col2"> <input name="mailing_list" type="checkbox" value="Please add me to the mailing list." /><font size="2">Please add me to the mailing list.</font>  </span></div> 


<div class="row"><label for='email' class="col1">Email:&nbsp;&nbsp;</label>
  <span class="col2">
  <input name="email" class="input" type="text" id="Email" size="20" tabindex="2"  style="font-size:17px;"/>
  </span></div>
  

<div class="row"><label for='message' class="col1">Comments:&nbsp;<br />Questions&nbsp;&nbsp; </label>
  <span class="col2">
  <textarea name="message" class="input" type="text" id="comments" cols="18" rows="5" tabindex="2" style="font-size:17px;"/></textarea>  
  </span></div>
  
  
<br /><br /><br /> <br /><br /><br /><br />
  <div class="row"><label class="col1">Security Code:&nbsp;&nbsp;</label>
  <span class="col2">
  
  <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' > 
  <br />
  <br />
  <input class="input2" id="6_letters_code" name="6_letters_code" type="text"><br /> 
  
  <div id="errorloc" align="center">
<?php 
if(!empty($errors)){
echo "<p class='err'>".nl2br($errors)."</p>";
}
?>
</div>

  </span></div> 
     
 </fieldset>  <div id="formbuttons"> <input type="submit" value="Submit" class="submitButton" name='submitButton'>  </div>
</form>
</div>
        <div id="footer"> </div>
</div>


<div class="copyright" >© 1999-2011test. All Rights Reserved.</div>


<script language="JavaScript">
// Code for validating the form
// Visit [URL unfurl="true"]http://www.javascript-coder.com/html...lidation.phtml[/URL]
// for details
var frmvalidator  = new Validator("contact_form");
//remove the following two lines if you like error message box popups
   //frmvalidator.EnableOnPageErrorDisplaySingleBox();
  //frmvalidator.EnableMsgsTogether();

frmvalidator.addValidation("name","req","Please provide your name"); 
frmvalidator.addValidation("email","req","Please provide your email"); 
frmvalidator.addValidation("email","email","Please enter a valid email address"); 
</script>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
	var img = document.images['captchaimg'];
	img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>

</body>
</html>

Artist/Designer
 
As per you first post, its probably the fact that while you are setting the $mailinglist variable from the POST variables, you are trying to have your email send $mailing[red]_[/red]list.
Notice the underscore between the words.

Code:
[red]$mailinglist[/red] = $_POST['mailinglist'];

....

 $body = "A user  $name submitted the contact form:\n".
        
        "Name: $name\n".
        "Mailing List: [red]$mailing_list[/red]\n".
        "Email: $visitor_email \n".

You should be getting an undefined variable notice, make sure display_errors is set to on in your php.ini configuration or at the very least set them at the top of your script when in development. You can remove setting when you go live, and are sure the code is working.

About your second post:
now i'm not getting the emails..... can anyone tell me why?

Nope, nobody can, because we can't see your PHP code in your site as it doesn't get delivered to the browser (no PHP code is ever sent to browser, that's just the way it works).

Post your new code here so we may see.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top