Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Connect and database verify */
- if(isset($_GET['id']))
- {
- include('../inc/connect.php');
- $id = $_GET['id'];
- // Fetch the record by ID
- $prep=mysqli_stmt_init($conn);
- mysqli_stmt_prepare($prep, "SELECT id, nev, email FROM tanulok WHERE id = ?");
- mysqli_stmt_bind_param($prep, "i", $id);
- mysqli_stmt_execute($prep);
- mysqli_stmt_store_result($prep);
- if(mysqli_stmt_num_rows($prep)==0)
- {
- $id=$nev=$email='';
- //+Hibaüzenet
- }
- else
- {
- mysqli_stmt_bind_result($prep, $id, $nev, $email);
- mysqli_stmt_fetch($prep);
- }
- mysqli_stmt_close($prep);
- }
- else
- {
- die("Record ID not specified.");
- }
- if(isset($_POST['id']))
- {
- include('../inc/connect.php');
- // Process the form submission and update the record
- $newName = $_POST['newName'];
- $newEmail = $_POST['newEmail'];
- $id = $_POST['id'];
- $prep=mysqli_stmt_init($conn);
- mysqli_stmt_prepare($prep, "UPDATE tanulok SET nev=?, email=? WHERE id=?");
- mysqli_stmt_bind_param($prep, "ssi", $newName, $newEmail, $id);
- mysqli_stmt_execute($prep);
- if(mysqli_stmt_affected_rows($prep)==0)
- {
- //Hibaüzenet
- }
- else
- {
- //Sikerült
- }
- mysqli_stmt_close($prep);
- header("Location: index.html"); // Redirect back to the records page
- }
- ?>
- <html>
- <head>
- <link rel="stylesheet" href="../css/main.css">
- <link rel="stylesheet" href="../css/w3.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/.../css/font-awesome.min.css">
- <title>Tanulói kezelőfelület</title>
- </head>
- <body>
- <div class="main-container-add w3-padding-large">
- <div class="w3-container w3-flat-peter-river margin-b80">
- <h2><i class="fa fa-address-card-o" aria-hidden="true"></i>Tanulói kezelőfelület</h2>
- </div>
- <h2 class="w3-text-deep-purple">Adatok módosítása!</h2>
- <form method="post" action="">
- <input type="hidden" id="id" name="id" class="w3-input" value="<?php echo $id; ?>">
- <label for="newName">Új név</label>
- <input type="text" id="newName" name="newName" class="w3-input" value="<?php echo htmlspecialchars($nev); ?>" required><br>
- <label for="newEmail">Új email:</label>
- <input type="text" id="newEmail" name="newEmail" class="w3-input" value="<?php echo htmlspecialchars($email); ?>" required><br>
- <input type="submit" class="w3-button w3-button w3-deep-purple" value="Módosítás!">
- </form>
- <a href="../php/add.php" class="w3-button w3-button w3-teal">Adatok felvitele</a>
- <a href="view.php" class="w3-button w3-flat-peter-river">Adatok megtekintése</a>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement