ho fatto qualcosa di più semplice senza js per ora:
Codice PHP:
<?php
session_start
();
if (isset(
$_SESSION['autorizzato'])) {
    echo 
"

Effettua il logout</p>"
;
    echo 
'[url="index.php"]Home[/url] | ';
    echo 
'[url="logout.php"]Logout[/url]';
    die;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Registrazione</title>
    </head>
    <body>
        [url="index.php"]Home[/url]
        <form method="post" name="inserisci" action="#">
            <table>
                <tr>
                    <td>User:</td>
                    <td><input type="text" name="user" /></td>
                </tr>
                <tr>
                    <td>Email:</td>
                    <td><input type="text" name="email" /></td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td><input type="password" name="pass" /></td>
                </tr>
                <tr>
                    <td><input type="submit" name="registra" value="Registrati"/></td>
                </tr>
            </table>
        </form>
        <?php
        
include("config.php");
        
$link mysql_connect($host$user$password) or die("Non è possibile connettersi al server
"
);
        
$conn mysql_select_db($db$link) or die("Non è possibile connettersi al db
"
);
        
$user mysql_real_escape_string($_POST['user']);
        
$email mysql_real_escape_string($_POST['email']);
        
$pass mysql_real_escape_string($_POST['pass']);
        
$query "insert into utenti values ('" $user "','" $email "','" $pass "')";
        
$controllo "select * from utenti where nome='" $user "'";
        
$result mysql_query($controllo);
        
$riga mysql_fetch_row($result);
        if (isset(
$_POST['registra'])) {
            if (
$user == null || $email == null || $pass == null) {
                echo 
"Dati mancanti";
                die;
            }
            if (
$riga[0] != "") {
                echo 
"Utente gia esistente";
                die;
            } else {
                
mysql_query($query$link) or die(mysql_error($link));
                
$_SESSION['autorizzato'] = $user;
                
header("location: index.php");
            }
        }
        
?>
        <?php

        
function valida_user($field) {
            if (
$field == "") {
                return 
"Non è stato inserito nessun User
"
;
            } else if (
strlen($field) < 5) {
                return 
"Lo User deve avere almeno 5 caratteri
"
;
            } else if (
preg_match("/[^a-zA-Z0-9_-]/"$field)) {
                return 
"Per lo User sono ammesse solo lettere lettere, numeri, - e _
"
;
            }
            return 
"";
        }

        function 
valida_email($field) {
            if (
$field == "") {
                return 
"Nessuna Email inserita
"
;
            } else if (!((
strpos($field".") > 0) && (strpos($field"@") > 0)) || preg_match("/[^a-zA-Z0-9.@_-]/"$field)) {
                return 
"L'indirizzo Email è invalido
"
;
            }
            return 
"";
        }

        function 
valida_password($field) {
            if (
$field == "") {
                return 
"Nessuna Password inserita
"
;
            } else if (
strlen($field) < 6) {
                return 
"La Password deve avere almeno 6 caratteri
"
;
            } else if (!
preg_match("/[a-z]/"$field) || !preg_match("/[A-Z]/"$field) || !preg_match("/[0-9]/"$field)) {
                return 
"La Password deve contenere almeno 1: a-z, A-Z e 0-9
"
;
            }
            return 
"";
        }
        
?>
    </body>
</html>
vorrei richiamare le funzioni ma nn so come fare.
nello specifico vorrei sostituire questo codice:
Codice PHP:
        if (isset($_POST['registra'])) {
            if (
$user == null || $email == null || $pass == null) {
                echo 
"Dati mancanti";
                die;
            }
            if (
$riga[0] != "") {
                echo 
"Utente gia esistente";
                die;
            } else {
                
mysql_query($query$link) or die(mysql_error($link));
                
$_SESSION['autorizzato'] = $user;
                
header("location: index.php");
            }
        } 
cioè quando è clicco sul bottone invece di fare quei controlli svolge quelli delle funzioni.
come posso fare?