Respuesta: quiero hacer que cuando registren elimine un numero php y esto es lo que tengo
<?php
require("includes/logincheck.php");
require("config.php");
require("includes/settings.php");
require("includes/extrasettings.php");
require("includes/cspuseroptions.php");
require("includes/functions.php");
$userexists = "false";
$nouserpass = "false";
$clearfields = "false";
$createpassword = "false";
$profileid = "";
$username = "";
$password = "";
$displayname = "";
$usrgroup = "";
$email = "";
$comment = "";
$customvalues = "";
$conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn);
$sql = mysql_query("SELECT * FROM cmum_settings WHERE id='1'");
$line=mysql_fetch_array($sql);
$autoloaddef = $line["autoloaddef"];
if ($autoloaddef == "1") {
$usedefaults = "true";
} else {
$usedefaults = "false";
}
mysql_close($conn);
if (isset($_POST["badduser"]) and $_POST["badduser"] == "Add user") {
$username = "";
$password = "";
$displayname = "";
$ipmask = "";
$profiles = "";
$maxconnections = "";
$admin = "";
$enabled = "";
$mapexclude = "";
$debug = "";
$email = "";
$comment = "";
$usrgroup = "";
$customvalues = "";
if (!isset($_POST["profiles"])) {
$profiles = "N;";
} else {
$profiles = serialize($_POST["profiles"]);
}
$username = trim(stripslashes($_POST["username"]));
$password = trim(stripslashes($_POST["password"]));
$displayname = trim($_POST["displayname"]);
$ipmask = trim($_POST["ipmask"]);
$maxconnections = trim($_POST["maxconnections"]);
$admin = strtolower($_POST["admin"]);
$enabled = strtolower($_POST["enabled"]);
$mapexclude = strtolower($_POST["mapexclude"]);
$debug = strtolower($_POST["debug"]);
$email = trim($_POST["email"]);
$comment = $_POST["comment"];
$usrgroup = $_POST["usrgroup"];
$customvalues = $_POST["customvalues"];
$username = replacechars($username);
$password = replacechars($password);
$displayname = replacechars($displayname);
$email = replacechars($email);
$comment = replacechars($comment);
$usrgroup = replacechars($usrgroup);
$customvalues = replacechars($customvalues);
if ($username == "" or $password == "") {
$nouserpass = "true";
} else {
$nouserpass = "false";
$conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn);
$sql = mysql_query("SELECT * FROM cmum_udb WHERE name='".$username."'");
$rowcheck = mysql_num_rows($sql);
if($rowcheck == 1){
$userexists = "true";
mysql_close($conn);
} else {
$userexists = "false";
mysql_query("INSERT INTO cmum_udb (name,password,displayname,ipmask,profiles,maxconn ections,admin,enabled,mapexclude,debug,comment,ema il,usrgroup,customvalues,added,addfin,addedby,idad min,changed,changedby) VALUES ('".$username."','".$password."','".$displayname." ','".$ipmask."','".$profiles."','".$maxconnections ."','".$admin."','".$enabled."','".$mapexclude."', '".$debug."','".$comment."','".$email."','".$usrgr oup."','".$customvalues."','".date("Y-m-d H:i")."','".date("Y-m-d H:i", strtotime("+1 Months"))."','".$_SESSION["loginuser"]."','".$_SESSION["loginuser"]."','','')") or die ("Error creating user");
mysql_close($conn);
header("Location: manusers.php?action=add&user=".$username);
}
}
}
if (isset($_POST["badduser"]) and $_POST["badduser"] == "Add user and stay") {
$username = "";
$password = "";
$displayname = "";
$ipmask = "";
$profiles = "";
$maxconnections = "";
$admin = "";
$enabled = "";
$mapexclude = "";
$debug = "";
$email = "";
$comment = "";
$usrgroup = "";
if (!isset($_POST["profiles"])) {
$profiles = "N;";
} else {
$profiles = serialize($_POST["profiles"]);
}
$username = trim(stripslashes($_POST["username"]));
$password = trim(stripslashes($_POST["password"]));
$displayname = trim($_POST["displayname"]);
$ipmask = trim($_POST["ipmask"]);
$maxconnections = trim($_POST["maxconnections"]);
$admin = strtolower($_POST["admin"]);
$enabled = strtolower($_POST["enabled"]);
$mapexclude = strtolower($_POST["mapexclude"]);
$debug = strtolower($_POST["debug"]);
$email = trim($_POST["email"]);
$comment = $_POST["comment"];
$usrgroup = $_POST["usrgroup"];
$customvalues = $_POST["customvalues"];
$username = replacechars($username);
$password = replacechars($password);
$displayname = replacechars($displayname);
$email = replacechars($email);
$comment = replacechars($comment);
$usrgroup = replacechars($usrgroup);
$customvalues = replacechars($customvalues);
if ($username == "" or $password == "") {
$nouserpass = "true";
} else {
$nouserpass = "false";
$conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
mysql_select_db($dbname, $conn);
$sql = mysql_query("SELECT * FROM cmum_udb WHERE name='".$username."'");
$rowcheck = mysql_num_rows($sql);
if($rowcheck == 1){
$userexists = "true";
mysql_close($conn);
} else {
$userexists = "false";
mysql_query("INSERT INTO cmum_udb (name,password,displayname,ipmask,profiles,maxconn ections,admin,enabled,mapexclude,debug,comment,ema il,usrgroup,customvalues,added,addfin,addedby,,ida dmin,changed,changedby) VALUES ('".$username."','".$password."','".$displayname." ','".$ipmask."','".$profiles."','".$maxconnections ."','".$admin."','".$enabled."','".$mapexclude."', '".$debug."','".$comment."','".$email."','".$usrgr oup."','".$customvalues."','".date('Y-m-d H:i')."','".date("Y-m-d H:i", strtotime("+1 Months"))."','".$_SESSION["loginuser"]."','".$_SESSION["loginuser"]."','','')") or die ("Error creating user");
mysql_close($conn);
$username = "";
$password = "";
$displayname = "";
$ipmask = "";
$profiles = "";
$maxconnections = "";
$admin = "";
$enabled = "";
$mapexclude = "";
$debug = "";
$email = "";
$comment = "";
$usrgroup = "";
$customvalues = "";
}
}
}
if (isset($_POST["badduser"]) and $_POST["badduser"] == "Create random password") {
$userexists = "true";
$createpassword = "true";
if (!isset($_POST["profiles"])) {
$profiles = "N;";
} else {
$profiles = serialize($_POST["profiles"]);
}
$username = trim(stripslashes($_POST["username"]));
$displayname = trim($_POST["displayname"]);
$ipmask = trim($_POST["ipmask"]);
$maxconnections = trim($_POST["maxconnections"]);
$admin = strtolower($_POST["admin"]);
$enabled = strtolower($_POST["enabled"]);
$mapexclude = strtolower($_POST["mapexclude"]);
$debug = strtolower($_POST["debug"]);
$email = trim($_POST["email"]);
$comment = $_POST["comment"];
$usrgroup = $_POST["usrgroup"];
$password = createpassword();
}
if (isset($_POST["badduser"]) and $_POST["badduser"] == "Create random user") {
$userexists = "true";
$createusername = "true";
if (!isset($_POST["profiles"])) {
$profiles = "N;";
} else {
$profiles = serialize($_POST["profiles"]);
}
$password = trim(stripslashes($_POST["password"]));
$displayname = trim($_POST["displayname"]);
$ipmask = trim($_POST["ipmask"]);
$maxconnections = trim($_POST["maxconnections"]);
$admin = strtolower($_POST["admin"]);
$enabled = strtolower($_POST["enabled"]);
$mapexclude = strtolower($_POST["mapexclude"]);
$debug = strtolower($_POST["debug"]);
$email = trim($_POST["email"]);
$comment = $_POST["comment"];
$usrgroup = $_POST["usrgroup"];
$username = createpassword();
}
if (isset($_POST["badduser"]) and $_POST["badduser"] == "Load defaults") {
$usedefaults = "true";
$username = $_POST["username"];
$password = $_POST["password"];
$displayname = $_POST["displayname"];
$usrgroup = $_POST["usrgroup"];
$email = $_POST["email"];
$comment = $_POST["comment"];
}
if (isset($_POST["badduser"]) and $_POST["badduser"] == "Clear fields") {
$userexists = "false";
$nouserpass = "false";
$usedefaults = "false";
$clearfields = "true";
$profileid = "";
$username = "";
$password = "";
$displayname = "";
$usrgroup = "";
$email = "";
$comment = "";
}
?> |