File manager - Edit - /home/custbahd/public_html/admin/edit.php
Back
<?php // including the database connection file include_once("config.php"); if(isset($_POST['update'])) { $id = mysqli_real_escape_string($mysqli, $_POST['id']); $username = mysqli_real_escape_string($mysqli, $_POST['username']); $email = mysqli_real_escape_string($mysqli, $_POST['email']); $image = mysqli_real_escape_string($mysqli, $_POST['image']); $password = mysqli_real_escape_string($mysqli, $_POST['password']); // checking empty fields if(empty($username) || empty($email) || empty($password)) { if(empty($username)) { echo "<font color='red'>Name field is empty.</font><br/>"; } if(empty($email)) { echo "<font color='red'>Email field is empty.</font><br/>"; } if(empty($password)) { echo "<font color='red'>Password field is empty.</font><br/>"; } } else { //updating the table $result = mysqli_query($mysqli, "UPDATE cadmin SET username='$username',email='$email',image='$image',password='$password' WHERE id=$id"); //redirectig to the display pcode. In our case, it is index.php header("Location: home.php"); } } ?> <?php //getting id from url $id = $_GET['id']; //selecting data associated with this particular id $result = mysqli_query($mysqli, "SELECT * FROM cadmin WHERE id=$id"); while($res = mysqli_fetch_array($result)) { $username = $res['username']; $email = $res['email']; $image = $res['image']; $password = $res['password']; } ?> <html> <head> <title>Edit Products</title> </head> <body> <a href="home.php">Back</a> <br/><br/> <form name="form1" method="post" action="edit.php"> <table border="0"> <tr> <td>Name</td> <td><input type="text" name="username" value="<?php echo $username;?>"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" value="<?php echo $email;?>"></td> </tr> <input type="hidden" name="image" value="<?php echo $image;?>"> <tr> <td>Password</td> <td><input type="text" name="password" value="<?php echo $password;?>"></td> </tr> <tr> <td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td> <td><input type="submit" name="update" value="Update"></td> </tr> </table> </form> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 0.48 |
proxy
|
phpinfo
|
Settings