Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $viewusername ="";
- // $viewcontactnumber = "";
- // $viewaddress = "";
- // $viewcountry = "";
- // $viewcity = "";
- // $viewzipcode = "";
- if ($_SERVER['REQUEST_METHOD'] == "POST") {
- if (ISSET($_POST['mydata'])) {
- $host = 'localhost';
- $user = 'root';
- $pass ='';
- $db = 'valocy';
- $con = mysqli_connect($host,$user,$pass,$db) or die(mysqli_error());
- $sql = "SELECT * FROM addressdetails WHERE email='haroondar0037@gmail.com'";
- if ($result = mysqli_query($con, $sql)) {
- if (mysqli_num_rows($result > 0)) {
- WHILE ($resultarr = mysqli_fetch_assoc($result)) {
- $viewusername = $resultarr['fullname'];
- // $viewusername = htmlspecialchars($resultarr['fullname'],ENT_QUOTES);
- // $viewcontactnumber = $resultarr['contactnumber'];
- // $viewaddress = $resultarr['address'];
- // $viewcountry = $resultarr['country'];
- // $viewcity = $resultarr['city'];
- // $viewzipcode = $resultarr['zipcode'];
- }
- } else {
- // use ELSE for better troubleshooting
- echo 'Warning: No record found';
- }
- } else {
- echo 'Error :' . mysqli_error($con);
- }
- }
- }
- ?>
- <?php include('includes/header.php'); ?>
- <br><br><br><br><br>
- <div class="col-sm-offset-3 col-sm-2 col-xs-offset-3" style="margin-top:5px;">
- <form method="POST" action="">
- <button type="submit" name="mydata" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">View My Data</button>
- </form>
- </div>
- <!-- Modal -->
- <div id="myModal" class="modal fade" role="dialog">
- <div class="modal-dialog">
- <!-- Modal content-->
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal">×</button>
- <h4 class="modal-title">Your Data</h4>
- </div>
- <div class="modal-body">
- <?php
- // check your $viewusername if is set here
- // coz you $viewusername may not be set due to no POST or query failure or no query result
- if (ISSET($viewusername)) {
- echo "name: $viewusername";
- } else {
- echo "name:";
- }
- ?>
- </div>
- <div class="modal-footer">
- <input type="button" name="close" value="close" class="btn btn-default" data-dismiss="modal">
- </div>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement