Ik maak een website waarbij je je kunt inschrijven op activiteiten.
Waar ik erg op vast loop is dat je aan de hand van je inlog gegevens kunt inschrijven op een activiteit.
Na op de submit knop activiteiten gedrukt te hebben wil ik dat hij de personeelsnummer uit de tabel personeelsgegevens haalt waar mee je bent ingelogd en die dan bij in de tabel inschrijvingen zet.
Zal iemand me hieruit kunnen helpen?
Dit is mijn code voor de login.
inloggen.php
login_query.php
dit is de activiteiten pagina (activiteiten.php)
en dit is de belangrijkste inschrijvingen.php waarbij dus de gebruiker aan de hand van het activiteit id en personeelsnummer waar die mee inlogt zich kan inschrijven
Ik hoop dat iemand de oplossing voor me heeft.
Waar ik erg op vast loop is dat je aan de hand van je inlog gegevens kunt inschrijven op een activiteit.
Na op de submit knop activiteiten gedrukt te hebben wil ik dat hij de personeelsnummer uit de tabel personeelsgegevens haalt waar mee je bent ingelogd en die dan bij in de tabel inschrijvingen zet.
Zal iemand me hieruit kunnen helpen?
Dit is mijn code voor de login.
inloggen.php
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| <div id="form2"> <img src="../Images/anker2.jpg"> <form action="../include/login_query.php" method="POST"> <div id="insideform"> <h4 class="text-success">Login</h4> <tr> <label>Gebruikersnaam</label> <input required type="text" class="form-control" name="username" /> </tr> <br> <tr> <label>Wachtwoord</label> <input required type="password" class="form-control" name="password" /> </tr> <br /> <div class="form-group"> <button class="btn btn-primary form-control" name="login">Login</button> </div> <br /> <br /> <br /> </div> </form> </div> |
login_query.php
code:
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
| <?php session_start(); if (isset($_POST['login'])) { if (isset($_POST['username']) && isset($_POST['password'])) { include_once("../include/dbcon.php"); $username = $_POST['username']; $password = $_POST['password']; $stmt = $conn->prepare("SELECT * FROM personeelsgegevens WHERE Personeelsnummer = :Personeelsnummer AND Voucher = :Voucher"); $stmt->bindParam(":Personeelsnummer", $username); $stmt->bindParam(":Voucher", $password); $stmt->execute(); if ($stmt->rowCount() == 1){ if($r = $stmt->fetch(PDO::FETCH_ASSOC)){ echo "<script>alert('Succesvol ingelogd'); window.location='../php/activiteiten.php'</script>"; $_SESSION["id"] = $r['Personeelsnummer']; $_SESSION["rol"] = "personeel"; exit(); } }else { $stmt = $conn->prepare("SELECT * FROM users WHERE user_name = :user_name AND password = :password"); $stmt->bindParam(":user_name", $username); $stmt->bindParam(":password", $password); $stmt->execute(); if ($stmt->rowCount() == 1){ if($r = $stmt->fetch(PDO::FETCH_ASSOC)){ echo "<script>alert('Succesvol ingelogd als admin'); window.location='../php/admin.php'</script>"; $_SESSION["id"] = $r['gebruikersID']; $_SESSION["rol"] = "admin"; exit(); } } ?> |
dit is de activiteiten pagina (activiteiten.php)
code:
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
| <?php include_once("../include/session.php"); include '../include/dbcon.php'; $stmt = $conn->prepare("SELECT * FROM activiteiten"); $stmt->execute(); if($stmt->rowCount() > 0) { while($r = $stmt->fetch(PDO::FETCH_ASSOC)){ echo <<< ACTIVITEIT <div class="ac"> <button class="collapsible">{$r['Naam']}</button> <div class="content1" style="display: none;"> <div class="ac-name">{$r['Naam']} | Nijmegen | Deadline: {$r['Deadline']}</div> <div class="ac-time"> <p class="ac-time-p-1">Tijden</p> <p class="ac-time-p-2">Plaatsen</p><br /> <div class="ac-input"> <form action="inschrijvingen.php?id={$r['ID']}" method="post" class="ac-form"> <p class="ac-pl">{$r ['Aantal']}/{$r['Aantal']}</p> <input type="radio" name="time" value="1">10:00-12:00<br /> <p class="ac-pl">{$r['Aantal']}/{$r['Aantal']}</p> <input type="radio" name="time" value="2">13:00-15:00<br/> <input type="submit" value="Inschrijven" class="ac-inschrijven" name="submit"/> </form> </div> </div> <div class="ac-dis"> {$r['Omschrijving']} <br> <br> </div> </div> </div> ACTIVITEIT; } } ?> <div class="table"> </div> </div> </div> |
en dit is de belangrijkste inschrijvingen.php waarbij dus de gebruiker aan de hand van het activiteit id en personeelsnummer waar die mee inlogt zich kan inschrijven
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| <?php include_once("../include/session.php"); include_once("../include/dbcon.php"); if(isset($_POST['submit'])){ $personeelsnummer = htmlentities($_POST['personeelsnummer']); $workshopid = htmlentities($_POST['workshopid']); $tijd = htmlentities($_POST['tijd']); $query = $conn->prepare("INSERT INTO `inschrijvingen`(`personeelsnummer`, `workshopid`, `tijd`) VALUES (:personeelsnummer,:workshopid,:tijd)"); $query->bindParam(":personeelsnummer", $personeelsnummer); $query->bindParam(":workshopid", $workshopid); $query->bindParam(":tijd", $tijd); $query->execute(); header("location: activiteiten.php"); } else { header("location:../php/activiteiten.php?message=6"); } ?> |
Ik hoop dat iemand de oplossing voor me heeft.