user3437313
user3437313

Reputation: 523

Fetch data from database in php

Hi In my application I designed one form with HallTicketNo if i click the submit button it will goto result page based on the hallticket no i want to fetch all the details.My proble is result.php it showing blank page fetching is not working can anyone help me

index.php:

 <html>
      <head>    
        <link rel="stylesheet" type="text/css" media="all" href="css/style.css">
        <link rel="stylesheet" type="text/css" href="css/style_register.css" />
        <link rel="stylesheet" type="text/css" media="all" href="css/responsive.css">
        <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="js/validation_script.js"></script> 
      </head>

      <body>
      <hr>
      <img src="images/banner1.jpg" width="100%" />
      <hr>
      <section id="container">
      <form id="result form" action="result.php" method="POST" enctype="multipart/form-data">  
      <div>
        <label class="desc" id="title1" >Hall Ticket No.</label>
        <div>
          <input id="name" name="uname" type="text" class="field text fn" value="" size="8" tabindex="1">
        <span class="val_name"></span>
        </div>
      </div>

        <div>
        <div>
            <input type="submit" name="submit_registration" value="Submit" /><input type="reset" name="reset" value="Reset" />
        </div>
        </div>  
    </form>
    </section>
    </body>
    </html>

result.php:

 <?php 
    session_start(); 
    if (isset($_SESSION['id'])) {
    ?>
    <html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">   
        <link rel="stylesheet" type="text/css" media="all" href="css/style.css">
        <link rel="stylesheet" type="text/css" href="css/style_register.css" />
        <link rel="stylesheet" type="text/css" media="all" href="css/responsive.css">
    </head>
    <body>
    <img src="images/banner.jpg" width="100%" />
    <section id="container">
    <?php
    include "../db.php";

    $hallticket = $_REQUEST["uname"];   
    $query = mysql_query("SELECT * FROM results where Hall_Ticket_No='$hallticket'");

    $row = mysql_fetch_array($query);   
    ?>
    <div id="title" align="center"><h3>Exam Results</h3></div>
    <div id="tab">
    <table align="center">

    <tr><td><b>HallTicketNo</b></td><td> : <?php echo $row['HallTicketNo'];?></td></tr>
    <tr><td><b>RNO</b></td><td> : <?php echo $row['RNO'];?></td></tr>
    <tr><td><b>FirstName</b></td><td> : <?php echo $row['FirstName'];?></td></tr>
    <tr><td><b>LastName</b></td><td> : <?php echo $row['LastName'];?></td></tr>
    <tr><td><b>ClassID</b></td><td> : <?php echo $row['ClassID'];?></td></tr>
    <tr><td><b>ClassName</b></td><td> : <?php echo $row['ClassName'];?>
    <tr><td><b>ExamID</b></td><td> : <?php echo $row['ExamID'];?></td></tr>
    <tr><td><b>ExamName</b></td><td> : <?php echo $row['ExamName'];?></td></tr>
    <tr><td><b>ClassResult</b></td><td> : <?php echo $row['ClassResult'];?></td></tr>

    <tr><td></td></tr>
    </table>
    <br>
    <div id="sign" align="right"><img src="images/sign.png" height=100 width=80></div>
    <br>
    <center><a href="index.php"><input type="button" value="home" /></a></center>
    </div>
    </section>
    </body>
    </html>
    <?php
    }
    ?>

Than you

Upvotes: 1

Views: 795

Answers (1)

dkakoti
dkakoti

Reputation: 667

In index.php you are not starting session and not registering session id. That is why the if condition of your result.php is not executing. In index.php do add this line.

<?php
session_start();
$_SESSION['id']= "1213"; //your id here
?>

Upvotes: 1

Related Questions