Gifari Industries - BD Cyber Security Team
Home
/
home
/
decohaslibrary
/
public_html
/
✏️
Editing: add_user_out_hod.php
<?php //strip the incoming text of any unwanted characters (SQL Injection attacks) function quote_smart($value, $handle) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value, $handle) . "'"; } return $value; } $msg = ""; $exist = false; $timailhan = false; if ($_SERVER['REQUEST_METHOD'] == 'POST'){ include 'sql.php'; if (isset($_POST['cancel'])) { print("<script>location.href = 'manage_user.php'</script>"); } $user = $_POST['uname']; $pass = $_POST['pword']; $grp = $_POST['group']; $pos = $_POST['position']; /*if(strlen($pass)>=11){ die("<SCRIPT LANGUAGE='JavaScript'>alert('password should be between 3 to 10!')</script><script>location.href = 'add_user.php'</script>"); }*/ if($user == ''){ die("<SCRIPT LANGUAGE='JavaScript'>alert('Please enter username!')</script><script>location.href = 'add_user.php'</script>"); } $SQL = "SELECT * FROM info"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { if ($user == $db_field['username']){ $exist = true; break; } } if ($exist){ $msg = 'User already exist!'; mysql_close($db_handle); } else{ $SQL = "SELECT * FROM info WHERE groups = '$grp' AND position = 'leader'"; $result = mysql_query($SQL); while($db_field = mysql_fetch_assoc($result)){ $led = $db_field['username']; if($led != ""){ $timailhan = true; } } $bui_pos = $pos; $bui_grp = $grp; $bui_user = $user; if($pos == "leader"){ if($timailhan){ die("<SCRIPT LANGUAGE='JavaScript'>alert('department has already a leader.')</script><script>location.href = 'add_user.php'</script>"); } } //unwanted HTML (scripting attacks) $user = htmlspecialchars($user); $pass = htmlspecialchars($pass); $grp = htmlspecialchars($grp); $pos = htmlspecialchars($pos); //function $user = quote_smart($user, $db_handle); $pass = quote_smart($pass, $db_handle); $grp = quote_smart($grp, $db_handle); $pos = quote_smart($pos, $db_handle); $SQL = "INSERT INTO info (`username`, `password`, `groups`, `position`) VALUES ($user, $pass, $grp, $pos)"; mysql_query($SQL); if($bui_pos == "leader"){ $SQL = "UPDATE group_title SET group_leader = '$bui_user' WHERE group_name = '$bui_grp'"; mysql_query($SQL); } mysql_close($db_handle); $msg = 'User successfully added.'; } } ?>
💾 Save
❌ Cancel