Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html><body background = "vv.jpg">
- </html>
- <?php
- echo '<h1>Delete a User</h1>';
- if ((isset($_GET ['id'])) && (is_numeric($_GET ['id'])))
- {
- $id=$_GET['id'];
- }
- else if ((isset($_POST['id'] )) && (is_numeric($_POST['id'])) )
- {
- $id=$_POST['id'];
- }else {
- echo'<p class="error">This page has been accessed in error.</p>';
- exit();
- }
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "test";
- // Create connection
- $link = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- if ($_SERVER['REQUEST_METHOD']=='POST'){
- if (!empty($_POST["sure"])){
- $q="DELETE from users WHERE user_id=$id LIMIT 1";
- $result = @mysqli_query($link,$q);
- if (mysqli_affected_rows($link)== 1){
- echo'<p>The user has been deleted.</p>';
- } else {
- echo '<p class="error">The user could not be deleted due to a system error.</p>';
- echo '<p>'.mysqli_error($link).'<br/>Query: '.$q.'</p>';
- }
- }
- else {
- echo'<p>The user has not been deleted.</p>';
- }
- }
- $q="SELECT mobilenum from users where user_id =$id";
- $result = @mysqli_query($link,$q);
- if (mysqli_num_rows($result)==1){
- $row=mysqli_fetch_array($result,MYSQLI_NUM);
- echo "<h3>User Name: $row[0]</h3>
- Are you sure you want to delete this user?";
- echo '<form action="delete_user.php" method="post">
- <input type="radio" name="sure"
- value="Yes"/>Yes
- <input type="radio" name"sure"
- value="No"/>No
- <input type="submit" name="sure" value="submit"/>
- <input type="hidden" name="id" value=
- </form>';
- }
- else{ echo '<p class="error">This page has been accessed in error.</p>';
- }
- mysqli_close($link);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement