1

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

3
  • 2
    Danger: You are using an obsolete database API and should use a modern replacement. You are also vulnerable to SQL injection attacks that a modern API would make it easier to defend yourself from. Commented Apr 26, 2014 at 9:56
  • Turn displaying errors on (stackoverflow.com/a/21427437/3110982) and check what causes the error. Besides that, you should really read about using PDO, especially read about SQL injections, as your code is vulnerable for that type of attack. Commented Apr 26, 2014 at 9:59
  • 1
    Have you checked if $_SESSION['id'] is set? use var_dump($_SESSION); as the top of the page after the <?php tag to check this. Commented Apr 26, 2014 at 9:59

1 Answer 1

1

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
?>
Sign up to request clarification or add additional context in comments.

10 Comments

hi can you tell me what is the id
@user3437313 the id you are checking in result.php in session if (isset($_SESSION['id']))
@user3437313 are you registering "id" in session somewhere.if yes than simply start session in index.php in <?php session_start(); ?> in top of index.php. Your session is broken.
$hallticket = $_REQUEST["uname"]; $query = mysql_query("SELECT * FROM results where Hall_Ticket_No='$hallticket'");
if i use the where condition it showing as a blank details
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.