<?php require_once('../../Connections/l.php'); ?>
<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="h";
$loginUsername = $_POST['username'];
$LoginRS__query = "SELECT username FROM dl_user WHERE username='" . $loginUsername . "'";
mysql_select_db($database_l, $l);
$LoginRS=mysql_query($LoginRS__query, $l) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO dl_user (id, username, nome, cognome, password, mail, actived, `data`, sito_web, auth) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['mail'], "text"),
GetSQLValueString($_POST['actived'], "int"),
GetSQLValueString($_POST['data'], "text"),
GetSQLValueString($_POST['sito_web'], "text"),
GetSQLValueString($_POST['auth'], "text"));
mysql_select_db($database_l, $l);
$Result1 = mysql_query($insertSQL, $l) or die(mysql_error());
$insertGoTo = "h";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_l, $l);
$query_Recordset1 = "SELECT * FROM dl_user";
$Recordset1 = mysql_query($query_Recordset1, $l) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td>
<td align="center" width="100">
Home</td>
<td width="20"></td>
<td align="center" width="100">
Registrati</td>
<td width="20"></td>
<td width="100" align="center" bgcolor="#999999">Registrati</td>
<td width="20"></td>
</tr>
<tr>
<td height="1" colspan="10" bgcolor="#CCCCCC"><table height="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
Registrati
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Username:</td>
<td><input type="text" name="username" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nome:</td>
<td><input type="text" name="nome" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cognome:</td>
<td><input type="text" name="cognome" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:</td>
<td><input type="password" name="password" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Mail:</td>
<td><input type="text" name="mail" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"></td>
<td><input name="submit" type="submit" value="Registrati"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</p>
</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>