Location: PHPKode > projects > WH Community > wh_community/recommend.php
<?php require('layout/header.php'); ?>

    <script type="text/javascript">
    	function showSuccessMessage() {
    	showNotification({
    	type : "success",
    	message: "<?php echo $lang['succes_recommend']; ?>"
    	});    
        }                                
    
    function showErrorMessage() {
    	showNotification({
    	type : "error",
    	message: "<?php echo $lang['couldnot_recommend']; ?>"
    	});    
        }                                
    </script>

<div id="content_wrapper">
    <div class="content"><?php
		
		echo '<h1>' . $lang['recommend_us'] . '</h1>';
		
		echo '<small>' . $lang['share_our_forum'] . '!</small><br><br>';

		$goto = 'recommend.php';
		$autoforward = 3;
		
		if($_SERVER['REQUEST_METHOD'] != 'POST') {
		
		echo '<form method="post" action="">
    		  <p><input type="text" name="name" id="name" size="40" maxlength="100" class="fields"> <strong>' . $lang['your_name'] . '</strong></p>
    		  <p><input type="text" name="email" id="email" size="40" maxlength="120" class="fields"> <strong>' . $lang['your_email'] . '</strong></p>
    		  <p><input type="text" name="toname" id="toname" size="40" maxlength="100" class="fields"> <strong>' . $lang['name_of_receiver'] . '</strong></p>
    		  <p><input type="text" name="toemail" id="toemail" size="40" maxlength="120" class="fields"> <strong>' . $lang['email_of_receiver'] . '</strong></p>
    		  <p><input type="submit" name="' . $lang['recommend_send'] . '" id="' . $lang['recommend_send'] . '" class="button" value="' . $lang['recommend_send'] . '!"></p>
    		  </form>';
		
    		}else{
    		
    		$name = htmlentities($_POST['name']);
    		$email = htmlentities($_POST['email']);
    		$toname = htmlentities($_POST['toname']);
    		$toemail = htmlentities($_POST['toemail']);
		
    		$errors = array();
    		
    		if(isset($_POST['name'])) {
                if(trim($_POST['name']) == "") {
                $errors[] = '<p>' . $lang['recommend_name'] . '.</p>';
                }
            
            if(isset($_POST['email'])) {
            $email = htmlentities($_POST['email']);
            
            if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) {
            $errors[] = '<p>' . $lang['recommend_email'] . '.</p>';
            }
            
            	}else{
            	$errors[] = '<p>' . $lang['recommend_email'] . '.</p>';
            	}
            
            if(isset($_POST['toname'])) {
            	if(trim($_POST['toname']) == "") {
            	$errors[] = '<p>' . $lang['recommend_toname'] . '.</p>';
            	}
            
            if(isset($_POST['toemail'])) {
            $toemail = htmlentities($_POST['toemail']);
            
            if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $toemail)) {
            $errors[] = '<p>' . $lang['recommend_toemail'] . '.</p>';
            }
            
            	}else{
            	$errors[] = '<p>' . $lang['recommend_toemail'] . '.</p>';
            	}
        
        if(!empty($errors)) {
        
    	echo '<p class="false"><u>' . $lang['not_filled_all'] . '</u></p>
    	      <p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p>';
    	echo '<ul>';
    
    	foreach($errors as $key => $value) {
    	echo '<li>' . $value . '</li>';
    	}
    	echo '</ul>';
    	echo "<script type=\"text/javascript\">showErrorMessage();</script>";
		
    		}else{
    		
    		$mailto = $toemail;
    		$subject = '' . $lang['hello'] . ' ' . $toname . ', ' . $lang['get_recommended'] . '.';
    		$message = '' . $name . ' ' . $lang['recommended_to_you'] . ':
-----------------------------------------------------------------
' . $forum . ' - ' . $title . '
-----------------------------------------------------------------

' . $lang['recomm_sender_mail'] . ': ' . $email . '';
	
		mail($mailto, $subject, $message);
		
		echo '<p class="right">' . $lang['succes_recommend'] . '</p>
		      <meta http-equiv="refresh" content="' . $autoforward . '; URL=' . $goto . '">
		      <p><em>(' . $lang['redirected_in'] . ' ' . $autoforward . ' ' . $lang['seconds'] . ')</em><p>';
		echo "<script type=\"text/javascript\">showSuccessMessage();</script>";
		
        }}}}
		
		echo '<div class="spacer_div">&nbsp;</div>';

		?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community