# PHP Security

**URL:** <https://forum.kirupa.com/t/php-security/195047>\
**Category:** flash\
**Created:** [July 28, 2006, 1:13am UTC](https://forum.kirupa.com/t/php-security/195047 "2006-07-28T01:13:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![atlnyc77](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@atlnyc77](https://forum.kirupa.com/u/atlnyc77)\
**Post date:** [July 28, 2006, 1:13am UTC](https://forum.kirupa.com/t/php-security/195047/1 "2006-07-28T01:13:03Z")

</div>

I build a php for a registration form for my website that i developed. Somehow security is one of my top priorities in protecting people information  
I read an article about filtering but i’m so confused because i’m so new at php. HEre is the original php code fragment.

```auto

<?php
$to = "whoever email address";
$subject = "Join CCF";
 
$userName = $_POST['visitor_name'];
$userEmail = $_POST['visitor_email'];
$userPhone = $_POST['visitor_phone'];
 
$headers = "From: ". $userName . "<" . $userEmail. ">
";
$headers .= "Reply-To: " . $userEmail . "
";
$headers .= "Return-path: ". $userEmail;
 
$message = "Name: " . $userName;
$message .= "
Email: " . $userEmail;
$message .= "

Phone: " . $userPhone; 
 
if (mail($to,$subject,$message,$headers)) {
  echo "output=Thanks for joining. We look forward of having you as a member";
} else {
  echo "output=error";
}

 

```

?\>

Here is the code from the article

```auto

Before submit:

$emailPattern = '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i';
    if (!preg_match($emailPattern, $emailFieldToTest)){
        print 'Please review the email address you entered. There seems to be a problem';
    }

After Submit:

function safe( $name ) {
   return( preg_replace(array( "\r", "
", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );
}

```

any ideas?
