Im learning PHP at the moment but for now i need to upgrade contact form i use
I need checkbox for accept policy rule for data processing

Here's part PHP before <html>

<?php 
error_reporting(E_ALL ^ E_NOTICE); // hide all basic notices from PHP

//If the form is submitted
if(isset($_POST['submitted'])) {

// require a name from user
if(trim($_POST['contactName']) === '') {
	$nameError =  'Forgot your name!'; 
	$hasError = true;
} else {
	$name = trim($_POST['contactName']);
}

// need valid email
if(trim($_POST['email']) === '')  {
	$emailError = 'Forgot to enter in your e-mail address.';
	$hasError = true;
} else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) {
	$emailError = 'You entered an invalid email address.';
	$hasError = true;
} else {
	$email = trim($_POST['email']);
}

// we need at least some content
if(trim($_POST['comments']) === '') {
	$commentError = 'You forgot to enter a message!';
	$hasError = true;
} else {
	if(function_exists('stripslashes')) {
		$comments = stripslashes(trim($_POST['comments']));
	} else {
		$comments = trim($_POST['comments']);
	}
}

// upon no failure errors let's email now!
if(!isset($hasError)) {

	$emailTo = 'youremailhere@googlemail.com';
	$subject = 'Submitted message from '.$name;
	$sendCopy = trim($_POST['sendCopy']);
	$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
	$headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

	mail($emailTo, $subject, $body, $headers);

    // set our boolean completion value to TRUE
	$emailSent = true;
}
}
?>

Form in html :

<div id="contact" class="section">
		<div class="container content">

        <?php if(isset($emailSent) && $emailSent == true) { ?>
            <p class="info">Your email was sent. Huzzah!</p>
        <?php } else { ?>

			<div class="desc">
				<h2>Contact Us</h2>

				<p class="desc">Please use the contact form below to send us any information we may need. It is required you place an e-mail, although if you do not need us to respond feel free to input noreply@yoursite.com.</p>
			</div>

			<div id="contact-form">
				<?php if(isset($hasError) || isset($captchaError) ) { ?>
                    <p class="alert">Error submitting the form</p>
                <?php } ?>

				<form id="contact-us" action="contact.php" method="post">
					<div class="formblock">
						<label class="screen-reader-text">Name</label>
						<input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="txt requiredField" placeholder="Name:" />
						<?php if($nameError != '') { ?>
							<br /><span class="error"><?php echo $nameError;?></span> 
						<?php } ?>
					</div>

					<div class="formblock">
						<label class="screen-reader-text">Email</label>
						<input type="text" name="email" id="email" value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" class="txt requiredField email" placeholder="Email:" />
						<?php if($emailError != '') { ?>
							<br /><span class="error"><?php echo $emailError;?></span>
						<?php } ?>
					</div>

					<div class="formblock">
						<label class="screen-reader-text">Message</label>
						 <textarea name="comments" id="commentsText" class="txtarea requiredField" placeholder="Message:"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
						<?php if($commentError != '') { ?>
							<br /><span class="error"><?php echo $commentError;?></span> 
						<?php } ?>
					</div>

						<button name="submit" type="submit" class="subbutton">Send us Mail!</button>
						<input type="hidden" name="submitted" id="submitted" value="true" />
				</form>			
			</div>

		<?php } ?>
	</div>
</div>

And in jQuery real time processing:

[CODE]$(document).ready(function() {
	$('form#contact-us').submit(function() {
		$('form#contact-us .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if($.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">Your forgot to enter your '+labelText+'.</span>');
				$(this).addClass('inputError');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test($.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">Sorry! You\'ve entered an invalid '+labelText+'.</span>');
					$(this).addClass('inputError');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#contact-us').slideUp("fast", function() {				   
					$(this).before('<p class="tick"><strong>Thanks!</strong> Your email has been delivered. Huzzah!</p>');
				});
			});
		}

		return false;	
	});
});[/CODE]

Your help would be appreciate very much !
Will buy a beer !πŸ™‚

    You forgot to mention what precisely your problem is. Just given us a mass of stuff which is most likely largely irrelevant.

      I wrote at the begining of post "checkbox for policy", but if it's not understandable then im sorry.
      Ok, I need to have checkbox for policy regulation - example ( I hereby agree for processing the following personal information strictly for the purposes of job recruitment in accordance with the regulation..) etc , so user has to agree with this regulations to send message.
      So when checkbox is "on" you can send message , when is "off" u cant.
      Hope i explained it clearly πŸ™‚)

        You still haven't explained what the problem is: what do you want us to help you with.

        If you're just wanting to find someone to do some work for you, there is the "Available Positions" forum.

          Yeah i missed those "Available Positions" forum.
          Sorry my bad.
          Thank you for helpπŸ™‚

            Thread moved to Available Positions forum.

            Note that most contributors here are glad to assist others in their endeavors to learn PHP (as opposed to being a source of free labor, for example).

              o got it, and thank you once more time all of you πŸ™‚

                Write a Reply...