here is my whole functions.php
<?php
//Arrays
//$error_array = array();
//Yeww web hosting's user defined functions
$error = 0;
$username = $HTTP_POST_VARS['username'];
function username_ok($username) {
if(preg_match('/^[a-zA-Z0-9][a-zA-Z0-9]{2,20}[a-zA-Z0-9]$/', $username)){
return true;
} else {
$error = error + 1;
//$error_array[]="Your selected username has a bad character";
}
//error_reporting( E_ALL );
//ini_set('display_errors','On');
$dbcnx = mysql_connect(localhost, root, "98@34back") or die("some code is mucked up" . mysql_error());
mysql_select_db(yewww) or die("some code is mucked up" . mysql_error());
$username = mysql_real_escape_string($_POST['username'], $dbcnx);
$sql = "SELECT username FROM free_unconfirmed WHERE username = $username";
$result = mysql_query($sql) or die(mysql_error());
if($result) { echo(ohshit); }
if(mysql_numrows($result) > 0){
$error = $error + 1;
return ($num_rows > 0);
}
if($error == 0){
return true;
} else {
return false;
}
}
?>
here is what calls the functions
<?php
require("functions.php");
$formatting = "noformat";
// $username = "";
if (isset($_POST['process'])) {
$username = $_POST['username'];
if (username_ok($username)) {
//store the data in the database...
header( "Location: unconfirmed.php");
}
$message = "Please enter a valid username thats not taken.";
$username = $_POST['name'];
$formatting = "errortext";
} ?>
the whole prg match part works