function sec($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $name = sec($_POST["n1"]); $email = sec($_POST["e1"]); $age = sec($_POST["a1"]); $gender = sec($_POST["g1"]); $password = sec($_POST["p1"]); //$query="INSERT INTO studs VALUES('$name','$email',$age);"; //MySQL Magic :D //Getting Resource ID $res_id = MySQLi_Connect('localhost', 'root', '@connectme', 'shangout'); if (MySQLi_Connect_Errno()) { echo "<tr align='center'> <td colspan='5'> Failed to connect to MySQL </td> </tr>"; } else { $check_email = MySQLi_Query($res_id, "select name from students where email='" . $email . "'"); $r_email = MySQLi_Fetch_Row($check_email); if ($r_email) { echo "<tr align='center'> <td colspan='5'> <font color='red'> Email already Registered, Registration Failed! </font> </td> </tr>"; } else { $count = MySQLi_Query($res_id, "select (max(id)+1) as count from students"); $count_id = MySQLi_Fetch_Assoc($count); if ($count_id["count"]) { $query = "insert into students values (" . $count_id["count"] . ",'{$name}','{$email}',{$age},'{$gender}','{$password}')"; } else { $query = "insert into students values (1,'{$name}','{$email}',{$age},'{$gender}','{$password}')"; }
Message(SPrintF('Права 0600 на файл конфигурации (%s) успешно установлены.', $File)); # пропускаем стадию с рассказом про триггеры и предложением их установки #$__STEP_ID = 5; $__STEP_ID = 6; } } else { Error(SPrintF('Не возможно создать файл конфигурации (%s)', $File)); } } } #------------------------------------------------------------------------------- if ($__STEP_ID == 6) { #----------------------------------------------------------------------------- if ($__SETTINGS['db-root']) { #--------------------------------------------------------------------------- $MySQL = @MySQLi_Connect($__SETTINGS['db-server'], 'root', $__SETTINGS['db-root'], $__SETTINGS['db-name'], $__SETTINGS['db-port']); if ($MySQL) { #------------------------------------------------------------------------- $Query = SPrintF("UPDATE `mysql`.`user` SET `Super_priv` = 'Y' WHERE `user` = '%s';", $__SETTINGS['db-user']); #------------------------------------------------------------------------- $Result = @MySQLi_Query($MySQL, $Query); if ($Result) { #----------------------------------------------------------------------- $Query = SPrintF("GRANT ALL ON `%s`.* TO '%s'@'%%';", $__SETTINGS['db-user'], $__SETTINGS['db-name']); #----------------------------------------------------------------------- $Result = @MySQLi_Query($MySQL, $Query); if ($Result) { #--------------------------------------------------------------------- $Query = 'flush privileges;'; #--------------------------------------------------------------------- $Result = @MySQLi_Query($MySQL, $Query);