<?php
/**
* @author Leroy Johnson
* @copyright 2010
*/
$server = "localhost";
$user = "root";
$pass ='';
if(isset($_POST) && count($_POST) == 3)
{
if(! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $_POST['email']))
$_POST['email'] = '';
$conn = mysql_connect($server,$user,$pass) or die(mysql_error());
$sql = "INSERT INTO online_users.users (id, first_name, last_name, email) VALUES (NULL, '".$_POST['fname']."', '".$_POST['lname']."', '".$_POST['email']."');";
$result = mysql_query($sql);
if(!$result)
echo mysql_error();
else
{ echo "<p style='color:red;'>User Added Successfully. </p>";
echo "<p><a href = 'chat.php'>Users online</a></p>";
unset($_POST);// prevent reinserting last record if refresh
}
}
?>
|