Du kan se om teksten kun indeholder tal og bogstaver med denne regular expression:
if(ereg('^[a-z0-9]*$', $string)){
...
måske ville det være smart også at tage de store bogstaver og æøåÆØÅ med 
Hilsen
Martin Dybdal (Dybber)
Mange tak, det er lige det jeg skal bruge.
Der er bare den detalje at jeg er PHP NOOB! :p Så det hjælper ikke rigtig. Jeg kan prøve at finde min kode frem.
function userCheck($uname, $email, $agreetoterms)
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$stop = '';
$res = pnVarValidate($email, 'email');
if ($res == false) {
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _ERRORINVEMAIL . "</div></span>";
}
// Check for legal module
if (pnModAvailable("legal")) {
// If legal var agreetoterms checkbox not checked, value is 0 and results in error
if ($agreetoterms == 0) {
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _ERRORMUSTAGREE . "</div></span>";
}
}
// By this test (without on printable characters) it should be possible to have
// eg. Chinese characters on the username. (hinrich, 2002-07-03, reported by class 007
if ((!$uname) || !(/**
* preg_match("/^[[:print:]]+/",$uname) &&
*/!preg_match("/[[:space:]]/", $uname))) {
// Here we test the uname. Any value is possible but space.
// On special character sets you might configure the server.
// (was bug #455288)
// if ((!$uname) || !(ereg("^[[:print:]]+",$uname) && !ereg("[[:space:]]",$uname))) {
/**
* if ((!$uname) || ($uname=="") || (ereg("[^a-zA-Z0-9_-]",$uname))) {
*/
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _ERRORINVNICK . "</div></span>";
}
if (strlen($uname) > 25) {
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _NICK2LONG . "</div></span>";
}
// Illegal Usernames [class007]
$reg_illegalusername = trim(pnConfigGetVar('reg_Illegalusername'));
if (!empty($reg_illegalusername)) {
$usernames = explode(" ", $reg_illegalusername);
$count = count($usernames);
$pregcondition = "/((";
for ($i = 0;$i < $count;$i++) {
if ($i != $count-1) {
$pregcondition .= $usernames[$i] . ")|(";
} else {
$pregcondition .= $usernames[$i] . "))/iAD";
}
}
// die ($pregcondition);
if (preg_match($pregcondition, $uname)) {
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _NAMERESERVED . "</div></span>";
}
}
if (strrpos($uname, ' ') > 0) {
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _NICKNOSPACES . "</div></span>";
}
$column = &$pntable['users_column'];
$existinguser =& $dbconn->Execute("SELECT $column[uname] FROM $pntable[users] WHERE $column[uname]='" . pnVarPrepForStore($uname) . "'");
if (!$existinguser->EOF) {
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _NICKTAKEN . "</div></span>";
}
$existinguser->Close();
$existinguser =& $dbconn->Execute("SELECT $column[email] FROM $pntable[users] WHERE $column[email]='" . pnVarPrepForStore($email) . "'");
// new by class007
if (pnConfigGetVar('reg_uniemail')) {
if (!$existinguser->EOF) {
$existinguser =& $dbconn->Execute("SELECT $column[email] FROM $pntable[users] WHERE $column[email]='" . pnVarPrepForStore($email) . "'");
$stop = "<div style=\\"text-align:center\\"><span class=\\"pn-title\\">" . _EMAILREGISTERED . "</div></span>";
$existinguser->Close();
}
}
return($stop);
}