-
Notifications
You must be signed in to change notification settings - Fork 4
/
addRegistration.php
49 lines (38 loc) · 10.7 KB
/
addRegistration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
include_once 'server.php';
$errors = array();
// Registering a new person to the database
if($_SERVER["REQUEST_METHOD"] == "POST"){
$username = mysqli_real_escape_string($db, $_POST['username']);
$email = mysqli_real_escape_string($db, strtolower($_POST['Email']));
$password = mysqli_real_escape_string($db, $_POST['password']);
//check db for existing person unique values
$user_check_query = "SELECT * FROM users WHERE email = '$email' or username ='$username'"; // this will be an SQL querie (SELECT statement) to check if primary key already exist
$results = mysqli_query($db, $user_check_query);
$user = mysqli_fetch_assoc($results);
if($user){
if($user['email'] === $email){array_push($errors, "Account already exists with this email!<br>");}
if($user['username'] === $username){array_push($errors, "Account already exists with this username!<br>");}
}
if(count($errors) == 0){
$query = "INSERT INTO users (username, password, email, profile_pic) VALUES ('$username','$password','$email',
0x89504E470D0A1A0A0000000D49484452000000E1000000E10803000000096D2248000000C3504C5445FFFFFFF54B55303442EEEFF0E54953FD4C56FA4C562C34422B2F3EFE4C562F33421332412733422025361833411D3341EC4A541B2133131A2E2233411D22340F172C171D30272B3BF4F5F6575A64EF4A54CF465172747C98999EDA4752C74550C4C5C8893D495B5E674B4E59444753E4E5E6DE48529E3F4BB6434EA3A4A9913E4AD7D8DACBCCCFB8B9BD666871783B47593845473644797B823C404DC0444FB1424D7E3C486339465437444236438F3E4A000D269D9EA3ACADB1A8414C6E3A4783858CEEC40C57000010CD49444154789CED5DE97AAACA128D8880208280E084C138C531319A3926BEFF535DB4BA017712AD06D4DC7B593FCEDEDF77B6348BAAAEA9BBABAFAE3264C8902143860C193264C8902143860C193264C8902143860C19FE9FD09FCE466EEBA6DBEDF596CB65AF5B9F6FDCB537A95DFABDD240DF735BCB6AD5B654C7917CC85BF87F3AAA5A31AACE7C33EB5FFA151360329ACB46459564EE57488E6548371F934BBF6A0CE4672DD5509D03E402C8926A58AD59FED2AFCC82FCBA6E5B0E825C4498965D5FFFB7CCCBD9DCB00E69E6AFA2B48CB977E9973F8EBE6B55A4EFAF2F964C532B2B8A52D6B67FF8FF35CD92F89DA4ADBA7F5B5BA7F3EABFCAE973F3292DEE3A9FB7CDF680E7759DE707CDD5EDB073B75014CD14FFE1A91AADE9A569FC0AAF5BDD179F6896B5C5D367932F160B0541107214FEDF8542A1280C56E3674E314B7B8274AADDBFC971DAB5A3FCC492567E195F37844284D937084231D7FEFCD2CA66549492D1F52E4DE71B26FBF22B95C5A755A378885C84663177DD79554AFB1CFF968FCC3F18117EA2A6DD5DE70A2876946441683E999A18E5D8FA4336676447EC4B49B97F6C30D1A3241B8F2F8A193EC831DC4B132398F42AE16B99DAD320063D4A72D0D12233D2EAFD0955752313D0D4C67C31263D40411F469455AA6E2E4DEF6AB254437EE6B85148C46FC731F72986BAAA721716E33A14604979D393F3DB716C8C43C32A55D717E4579B1B81FD54BEF874F801C73B85AAAA6CCF2F1691F7B9C0846A8B667AFC761C9BAF5A6054B90B65C95EA0A1A232C4F9760608C2B04CC52855BD4B10FCA806027C69A72B404061F01288B13A3A3FC18D1108709CBA000182300E66A3B13937C116F5F225F13A99073C844293A346B5D23A2FC11BEA05B567FD34020408FA3DD554757E4E82756A4495CE2966E01EC78E4229DE9C9FA0A87C9E4E43298A9F01C5FAB908521515CBCDD313F429AEA8DB3897A2CE2941B37DCA2918A2D0A6F986F5700E821B6245456E701E82FE5C6CD3BA9C7D869471645082FCB908FA140794E2E9E3708F4432A2784682118A72F5C475B83E25583A9B8A128A6D9217CB95D3966F9612B1A2673232118A4DE234A4E529095233AA5C9F9BA06F51AF0945E784F1DB9A5899648E7E5BEE2EECD7C051085C7F75762A8274126A9D5804B7A57CA1D818AC864F77774F9DF16DB351642259EC9018D5385546DC8349587A6156515F6A02DFBCFD1C0E9F4B8A66967C98A6A698F7C3010BC9C20B641A52EF34045D8BF8099D95DEE0F16E5156CA9A69EE2FC2F8619172BFCAE139EA64A5CA3A89E39F101D559A6CE57A7EF85AD6BEAF150624CBDC2DBA844C0DAA5C3D859E121DD5DE1826A1203CDE2BE6AFEC0847055F05298EB593E9E908C251718197A0CF8F2B1FA14738A28DB3F0020FACA45EB8C953478177F5C5F6E2277EB2A4AA15BB62ED6DD450EEB00C0765F84525ED226A0B925E6D88CEE90B61190998398E6A552A863CFF587B536FEDB696861A9034170DE46387A0A74ECA89143133E22BDA26349EB5909DA4DAEF72CB5DCF665E741962E23A36E5585A609FFC0A1FAE9AEE82461DCC0C3A5A13782E5C79B02A37A3DFF6B0794B8B4AF11EF76C81446F52AA358D2988B0F485D45161106CB190ECE5E19D406E958851BBC3999BC2177CBC54F3A82E11218F24483DB39FEBF48EBEC7C421AB03CA2D4E8A7CFA42F4C0909A63AC9979252A2AA1AAF1798E50D4705FB03086F545C34B8D2188502C61CDDD1759E17496386B909748C4FB85D3D306A888D44D8B2031A426D253088F24CBC1D737FBA4BA85B46485A199AE399D83084D143F3F3C266EC261A851CF8837BAC77DC406F18929E5C27D361116EF488AC3A44324A2C00A91CEC4740270978433B8A429A8A7184C15A3BC0D33F11937137560A8A69345416DC644AEC1149F4BB10C9DABB238A44267475176D220E881155006A8A185B6126F8AD46C3217705BE1C830761A5EFF4602F5C189B0F044020EE6AAE6663719B0D95901B2A8346C4D1EEC8CB6C28DDC806CDED9300F343158D4547804736A274FA2D616787BD4B83961B54BDF643B8691832282860CDD72A02B56F2CA226415A527A49282AB90E22CF481CD2EDD314D875823ED210F091CB6FC248015AF7831869AEE6C8DC8E1FC05D116CE4AAAA6B30A0C8B549D3628A9116B58F898656CB11266BCED2564F8E0B028A9F0B99BFF52BC3D0510E09791EA4226440C9BB60F28179591B93D991CEA47ACB1E06B6A8FC809B1DA7D4D994B469098700D35A6CFF07EA73995787E78A432F87CDF31C1444C581C5EAB2CD1622EC7C1DC88B78839B3586644AE084E3FA1BF80909FF5B3C68C16C19862A3A79C000946C2B22227B34CFEDC60172DCA315769FBBB2981CD1173C27539C968644C120E23CB1742B39CC09452862FD86A10C98363CE098067C7F9AA52CC70187244FCCA0889BE13E517C4BA61B7E711031ED745E521BA40D7D50B1DF04D49B6D8B079A89418A265287C9A897D7E8F29CA0818C6B46E30EB45F4223A9DF6498A8A901B2A484393741E32DAD25C4E8744BF1A9F20C97E4DF4F265325B3A011962FDA1EFF321F84E10D590215FD0EBDAED44FE102A42D80471CB1082443B7E619879C806593389371C446D68CB1DA417B1B2510071166FF8A5FB5D5C1A77739DCB1622FAB3E2CD4CE82EA086A97DE2874CE483210846176A027791A02EBC611D92E687F13E6A9DCD3725F64E3E5A50FD421612C38F1A7348A87A9791CBB0B9C4DEE98A1683593E2AB88B78C576B20254C29FE0A0DE297EBD0D0A274A1B3D642E9760610F2CB7788FDF732540E12BC1723761885BB1D841873A6DAC89F841B4946138C84713846D84217E6214DEC8AA579C3D591F6C8B5C5BF04919F65819D2DD3CEF71E2A8FEFBEEB722871E8E3094E36FE3636648F68158F1BC85079B8798C74BB05191751E52531AB772C2EC10DB29CD435686B1AD3724DCD8F2731A0922F9A6F80D9709BF698B95E175A26CED8A6E33C18F4867FEB9B494446D09621A52A6C1476DA422ACC65CF182EA2CDED208B789EA4257349D4117A2026F113325A5D559EC683901F64639F1730B921F8EF1B9C55792B527C880F115E184A94C3864E98E35B7883911611A327C50E11996BABCD80C499DE61E3B2235A69C11270526B9058361CB259A14BB31A1BC2762AB89B95C71117F5F24D92058C213A42B8809162EAAAC611459E6E6D40DB339FD80BD57E61B3EF026A53D233EC1AB2559E3C69F746A901332AC6DACD6157AB4119F3CE9C41D26393F4316483F19F2A7213D8460B3943236B4518AF9844F80F561F2255297AC3DE978210A1CDDA5CFD0AB636393DF88E8BD263E411DCAA5B192510A525878D11966623B380A646F90C3B8413326051F3FE5787D917CFD904419A5018F37A78555701A08799C959E80E744E5116F661AFC000A0A89D680E93AFE8AC70BD197E282F6EA4015BF6BF4F45399A9D914CF930D35C9CE7643C5D41CEA0C42CC09C28A5A544CA648B6788BDA2DCBD9E706AFBFA5B117032253F1BEC122C46D6F2072860E5156A46753CB6CDDC278BE91CA7E1A124969039E4588BBC9B8FB212239BD21278E6E9908FA9F7C90CA9EA82B6879ACDDEA6C42CC15EF90E7052032F4C37BB613F03CAF437228C75CCA0B40F726FA0CD98E7093F30247733772D6C1647CBAFF3A646F62D29396747F29CF330A911CFA386AE92030648946B7D8BE8E98347502D4201EDEFA0B468AA476FA7ED861F499837B4A10943485F3C090D394EE7CBD60333624913AF28D49D4B4609A85BE99A14A9AA0CE4601793E57E2598548B60E1EA9687CB0164AB6D8BD0BD9AB9FBCE71039CBA27D6E85C8620E6821ECB025605E66CEEDCC0CAF934434DE8EF27D40C8B18DBED9F494966B0F87352DD6922CE828AF83BB4F7E18E18AEE4FE49426A39EE2B60F312F33131D2527E4125BD21D2030065BC34051B8D610A12918328D4186BBB7D0C9F12A350D82F4DC9CD6866763DF841CD33B5290867988DF489E83EFDC4EF5FC61DF00A7DC818723A762919C063E12181353AD3C222936E033435A21B39DE2FC1D24BD31791E4FB1784B3BC91C367635D26F4059A12836C83B909030AD9E58F42CF7188488998AC5E03CF7E6C8C337B4C6869222BC803E4EF92C37ED8A610E781C4521683A2A3BC7FC5590E12B9DE30930197F10E72CF5414C494F0532138F512CB45F6953754413E7A04A63BE1ECB81C9E87A8764662936C6A0AD4DDAFC718A42EE2D2C456116A13EC242D4DBC1AE5874F0F6099A9B04BD4DF4A3148BD75CD015BF8A33E66ED037DBE456BF8B910EADD3DE26A936A821422CAF8E502CF05F61BBF8776CA976F44EFBF088CAF36FCDEB0382E468650A594514418FA180E14F1485DC30D2F2DFF2D08FF7ACC80504E31F55351897E74ED26328F0896FBF53148AABB0173E67D759BC71BE1EDE02A2BDAEBE37E20B46A56626F1C9CA7F4192283F0BE07FA1586CDF87ADAF249B356F1B8537D588CA7DBBF80B411E3216841B6246D0AF2D146234BA111A9D504165E3863D9CEADF1841E7AF92D26944C4D80887E4C9CE39FB04FD2F4973D6D02946280A85DBE8BD224EBCE1674EE4BE1331EC351821A83FC130293AFB1041DFC4DB0845C8340A83FBB0F79C54655FFF25A86DC22B4FC4F2FD00AC6A74B8DB53F64DA45994586AF311ECAE30284714B49EC4C64DEA11552DEF6ECD880ED6261DB62AF1B6B31CC592F62FD5A3A30A91DB4438954B3A3F665CA8AADA6B53880EA52FE04B3AA76A3F4FF5D4BC8BCE8C4E68419DF7343252F73DB8DC4554F6663D592948B8627808B48F70794C29EACD452040B93A4F67E4FCBC1AA8AAB668538E8D215DD03A591FE1ABABB9B36F6D1A8FC1ED53B2CA79A98DE37141CF48517B6CEC59194E3DE95D1E642A9200550FEE9EE0A4942F4973C30000349586A3276B224CD0A75DF5B56B7FD8B0BDA58AEC3D87C7A44B5B4672DAF3763A9CA9273BCDA37C9FD1E417D4C9CB55B756CBA71946F94FAB052D233973C137B933F5D58FDE8DB0A04ED0594E6BF92DD2E2489E360D6ECC2A2DE82E9D735C8B4477F704ED2DED561E5E29258EE1C3F22DDAC0950E768EFB2DAEAE1E8209020447C12BA540F29F678D8CBD8B85CF734749787FC0CEB2A9DEFE4B25E2F8FD519E1AB9FEF37C172205B73D7172AFFFEDADE292FCF941FD5E20C5735E87145074363FBE173BC9DF1FB3712E4030A2A86AFD6721C2DBE158D60E3CA15F57CFAEA28016DD2F29C9DF27229EE60172BBDF7A329560E5CC0423454E70F7C750DB2242AC86FA4DE8F4CF7F77DEB66D2C1DDDEA4E8EBF2E3B6A91C0ED12F71FFA916350E494EC0F844818F9D5C2E0FB427758FA795C2FF01A566F9A2EC59A173EDC595EE81E521F0FC18A8364B40E1855667EFD562040D938F3DD8EFB9885699C63BBF97438D6F2AE1114322E7B1FB08F7E9DBA0DDF6349A31438FAFC9C20C397FFC2D5DC9172BCAC3A6E325DADD5FA6E25BCF54242AECF9D18FD6E704985CF51DD4C62DBD55A6DFA50895C445FF9030204ACD5C86B39D5FA3A1F83A4FF9375D7883E28519BB29451DB18912447B2D496C746D2FFC7B3966A451F62C45E1C380D26F56AE4F538A7223FCCF298D06C17D0F5670F72543DFD09986871E03498D6A372E464C7B2EBAE973F18816EFF67DF73EBB615BD38C8975FFDE4F5A6589876AB7B2F2A4B4E45ED6E465EBF4610F2DAA13F1D6DBAAAED44BFCC762277FF26BF2D262D43E5F621396AC5B07BADCD683D9B4E2693FE643AF566EB8F4DABAB566DF51F76BE53ADB6FE9E7E469177555B92B97FE18B5355AD8A6D1B866D572A96AA3ADFB86DFF5545752F1783A2E1CD0DEBFBDB1F87641973EFD22F8F446D5DB7F74CE3516CEDD2CDFAC4F5FA74B1756F86FA83BEFEC04E520DE761F6B7BC1F0E93D19CB32B7B37C87D139D5331B8F9E86FDB96C3F0BD5D6BF95EF589FA6633C4F69639BBFABE6CB9B3FF02CB82407FE28DDCCDBC5EEF6E51AFCF37EE6836F9DFE0962143860C193264C8902143860C193264C8902143860C193264C880C57F00AB008D01FAEE4FFF0000000049454E44AE426082)"; //This is where the SQL querie will go (Insert statement), to add the person if no errors
mysqli_query($db,$query);
echo("User account created succesfully.<br>You will be redirected to the login page momentarily.<br>");
//sleep(2);
// redirect to home page
// may be changed depending on html implementation
echo("<meta http-equiv=\"refresh\" content=\"5; url=login.php\" />");
}
else{
//Failed.php is a placeholder for an unsuccesful request
//May be changed depending on html implementation
//header("Location: Failed.php");
while(count($errors) != 0){
echo(array_pop($errors));
}
echo("User account creation failed. Please try again.<br>Page will refresh momentarily.<br>");
echo("<meta http-equiv=\"refresh\" content=\"5; url=registration.php\" />");
}
}
?>