registrace v1
This commit is contained in:
@@ -20,8 +20,15 @@
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$races[] = $row;
|
||||
}
|
||||
}else{
|
||||
echo "0 results";
|
||||
}
|
||||
// would be nice to check if the name / nick / email exists
|
||||
$sql = "SELECT ID, NAME, SURNAME, EMAIL from REGISTERED where EMAIL_CHECK like '".$email_check."'";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0){
|
||||
$unique_email = False;
|
||||
}
|
||||
else{
|
||||
$unique_email = True;
|
||||
}
|
||||
$conn->close();
|
||||
//var_dump($races);
|
||||
|
||||
57
www/lib/write_registered.php
Normal file
57
www/lib/write_registered.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?
|
||||
$servername = "db";
|
||||
$username = 'kalskeborec';
|
||||
$password = 'Kalskeborec1!23$';
|
||||
$db = 'kalskeborec';
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($servername, $username, $password, $db);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// would be nice to check if the name / nick / email exists
|
||||
$sql = "SELECT ID, NAME, SURNAME, EMAIL from REGISTERED where EMAIL_CHECK like '".$email_check."'";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0){
|
||||
$unique_email = False;
|
||||
}
|
||||
else{
|
||||
$unique_email = True;
|
||||
}
|
||||
|
||||
// Geting the values from the script above. -< register.php
|
||||
|
||||
if($unique_email){
|
||||
$stm = $conn->prepare("INSERT INTO REGISTERED (ID, NAME, SURNAME, EMAIL, PHONE, NICK, RACE, TIME, TRACKLOG, EMAIL_CHECK, CONFIRMED, PAID)
|
||||
values (NULL,?,?,?,?,?,?,'[None]','[None]',?,'0','0')");
|
||||
$stm->bind_param('sssssss',$fname, $lname, $email, $phone, $nick, $race_to_write, $email_check);
|
||||
|
||||
|
||||
if ($stm->execute() === TRUE) {
|
||||
//echo "New record created successfully";
|
||||
$sql = "SELECT ID, NAME, SURNAME, EMAIL, PHONE, NICK, RACE from REGISTERED where EMAIL_CHECK like '".$email_check."'";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows == 1){
|
||||
while($racer = $result->fetch_assoc()) {
|
||||
$racers[] = $racer;
|
||||
}
|
||||
$write_success = ["result"=> True, "reason" => "Prihlaseno"];
|
||||
$logged_racer = $racers[0];
|
||||
}
|
||||
else{
|
||||
$write_success = ["result"=> False, "reason" => "Error: Duplikatni zaznam zavodnika, napis Ventilovi"];
|
||||
}
|
||||
} else {
|
||||
$write_success = ["result"=> False, "reason" => "Error: " . $stm . ": " . $conn->error];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$write_success = ["result"=> False, "reason" => "Zavodnik_s_timto_emailem_uz_existuje"];
|
||||
}
|
||||
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user