Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. <?php
  2. // $viewusername ="";
  3. // $viewcontactnumber = "";
  4. // $viewaddress = "";
  5. // $viewcountry = "";
  6. // $viewcity = "";
  7. // $viewzipcode = "";
  8.  
  9. if ($_SERVER['REQUEST_METHOD'] == "POST") {
  10. if (ISSET($_POST['mydata'])) {
  11. $host = 'localhost';
  12. $user = 'root';
  13. $pass ='';
  14. $db = 'valocy';
  15.  
  16. $con = mysqli_connect($host,$user,$pass,$db) or die(mysqli_error());
  17. $sql = "SELECT * FROM addressdetails WHERE email='haroondar0037@gmail.com'";
  18. if ($result = mysqli_query($con, $sql)) {
  19. if (mysqli_num_rows($result > 0)) {
  20. WHILE ($resultarr = mysqli_fetch_assoc($result)) {
  21. $viewusername = $resultarr['fullname'];
  22. // $viewusername = htmlspecialchars($resultarr['fullname'],ENT_QUOTES);
  23. // $viewcontactnumber = $resultarr['contactnumber'];
  24. // $viewaddress = $resultarr['address'];
  25. // $viewcountry = $resultarr['country'];
  26. // $viewcity = $resultarr['city'];
  27. // $viewzipcode = $resultarr['zipcode'];
  28. }
  29. } else {
  30. // use ELSE for better troubleshooting
  31. echo 'Warning: No record found';
  32. }
  33. } else {
  34. echo 'Error :' . mysqli_error($con);
  35. }
  36. }
  37. }
  38. ?>
  39. <?php include('includes/header.php'); ?>
  40.  
  41. <br><br><br><br><br>
  42. <div class="col-sm-offset-3 col-sm-2 col-xs-offset-3" style="margin-top:5px;">
  43. <form method="POST" action="">
  44. <button type="submit" name="mydata" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">View My Data</button>
  45. </form>
  46. </div>
  47.  
  48. <!-- Modal -->
  49. <div id="myModal" class="modal fade" role="dialog">
  50. <div class="modal-dialog">
  51. <!-- Modal content-->
  52. <div class="modal-content">
  53. <div class="modal-header">
  54. <button type="button" class="close" data-dismiss="modal">&times;</button>
  55. <h4 class="modal-title">Your Data</h4>
  56. </div>
  57. <div class="modal-body">
  58. <?php
  59. // check your $viewusername if is set here
  60. // coz you $viewusername may not be set due to no POST or query failure or no query result
  61. if (ISSET($viewusername)) {
  62. echo "name: $viewusername";
  63. } else {
  64. echo "name:";
  65. }
  66. ?>
  67. </div>
  68. <div class="modal-footer">
  69. <input type="button" name="close" value="close" class="btn btn-default" data-dismiss="modal">
  70. </div>
  71. </div>
  72. </div>
  73. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement