3 Replies - 663 Views - Last Post: 25 August 2016 - 11:40 AM Rate Topic: -----

#1 saktisingh7   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-August 16

Script error

Posted 25 August 2016 - 11:03 AM

i have problem in a script. i have created online eam system everything is going well on wamp when i uploaded it on my hosting account registration is running but i am unable to loging. there is no error when i enter credentials. it just reload. is there anyone one who can help with this script? my php version is 5.4.here is my code:
 <?php
     error_reporting(0);
      session_start();
      include_once 'oesdb.php';
/***************************** Step 1 : Case 1 ****************************/
 //redirect to registration page
      if(isset($_REQUEST['register']))
      {
            header('Location: register.php');
      }
      else if($_REQUEST['stdsubmit'])
      {
/***************************** Step 1 : Case 2 ****************************/
 //Perform Authentication
          $result=executeQuery("select *,DECODE(stdpassword,'oespass') as std from student where stdname='".htmlspecialchars($_REQUEST['name'],ENT_QUOTES)."' and stdpassword=ENCODE('".htmlspecialchars($_REQUEST['password'],ENT_QUOTES)."','oespass')");
          if(mysql_num_rows($result)>0)
          {

              $r=mysql_fetch_array($result);
              if(strcmp(htmlspecialchars_decode($r['std'],ENT_QUOTES),(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0)
              {
                  $_SESSION['stdname']=htmlspecialchars_decode($r['stdname'],ENT_QUOTES);
                  $_SESSION['stdid']=$r['stdid'];
                  unset($_GLOBALS['message']);
                  header("Location: stdwelcome.php");
              }else
          {
              $_GLOBALS['message']="Check Your user name and Password.";
          }

          }
          else
          {
              $_GLOBALS['message']="Check Your user name and Password.";
          }
          closedb();
      }
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>Online Examination System</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="oes.css"/>
  </head>
  <body>
      <?php

        if($_GLOBALS['message'])
        {
         echo "<div class=\"message\">".$_GLOBALS['message']."</div>";
        }
      ?>
      
      <div id="container">
            
                <div class="header">
                <img style="margin:10px 2px 2px 10px;float:left;" height="80" width="200" src="images/logo.gif" alt="OES"/><h3 class="headtext"> &nbsp;Online Examination System </h3><h4 style="color:#ffffff;text-align:center;margin:0 0 5px 5px;"><i>...because Examination Matters</i></h4>
            </div>
     <form id="stdloginform" action="index.php" method="post">
      <div class="menubar">
       
       <ul id="menu">
                    <?php if(isset($_SESSION['stdname'])){
                          header('Location: stdwelcome.php');}else{  
                          /***************************** Step 2 ****************************/
                        ?>

                     <li><div class="aclass"><a href="register.php" title="Click here  to Register">Register</a></div></li>
                        <?php } ?>
                    </ul>

      </div>
	 
      <div class="page">

               <h2 style="text-align: center;"><span style="color: #ooofff;"> &nbsp;EXAMINEE LOGIN</span> </h2>
              <table cellpadding="30" cellspacing="10">
              <tr>
                  <td>User Name</td>
                  <td><input type="text" tabindex="1" name="name" value="" size="16" /></td>

              </tr>
              <tr>
                  <td>Password</td>
                  <td><input type="password" tabindex="2" name="password" value="" size="16" /></td>
              </tr>

              <tr>
                  <td colspan="2">
                      <input type="submit" tabindex="3" value="Log In" name="stdsubmit" class="subbtn" />
                  </td><td></td>
              </tr>
            </table>

<h3 style="text-align: center;"><span style="color: #ooofff;">&nbsp;If new click here to<a href="register.php"  title="Click here to register">&nbsp;Register Yourself</a></span> </h3>
<br>
      </div>
       </form>

This post has been edited by astonecipher: 25 August 2016 - 11:14 AM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Script error

#2 benanamen   User is offline

  • D.I.C Regular

Reputation: 39
  • View blog
  • Posts: 251
  • Joined: 28-March 15

Re: Script error

Posted 25 August 2016 - 11:09 AM

That is some really bad code. You are using obsolete code that has been completely removed from PHP. Your php version is over one hundred versions behind. You should be running no less than ver 5.6x

This post has been edited by benanamen: 25 August 2016 - 11:11 AM

Was This Post Helpful? 0
  • +
  • -

#3 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6888
  • View blog
  • Posts: 31,704
  • Joined: 10-May 07

Re: Script error

Posted 25 August 2016 - 11:30 AM

View Postsaktisingh7, on 25 August 2016 - 02:03 PM, said:

there is no error when i enter credentials. it just reload.

Can you check the server logs for server logged errors from php, not just relying on them to display on the website.
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2803
  • View blog
  • Posts: 8,149
  • Joined: 15-January 14

Re: Script error

Posted 25 August 2016 - 11:40 AM

Well of course there aren't any error messages, you're telling it to hide them:

error_reporting(0);


How come halfway down when you're printing out the HTML, you check if something is set in the session and then redirect them? Shouldn't you do that first? Why output all of that HTML if you're just going to redirect them? All of your program logic should go at the top of the file, before you output anything. You only start outputting HTML if you know that they need to see something. If you're just going to redirect then there's no reason to print a bunch of HTML, and then you can turn error reporting back on since you're not trying to send a location header after you started output.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1