473,480 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Php header is not working on server...

5 New Member
hello...
my entire project is working fine.
but when i uploaded it on host..
it doesnt work..
prb arise when i enter correct username and password..
thenafter i doesn;t get redirected to destined page

thanks
Apr 18 '13 #1
9 2675
johny10151981
1,059 Top Contributor
Give us the code please........
Apr 19 '13 #2
chirag vora
5 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4.  
  5.  <?php
  6.  
  7.  
  8.       error_reporting(0);
  9.       session_start();
  10.       include_once 'oesdb.php';
  11.  
  12.       if(isset($_REQUEST['register']))
  13.       {
  14.             header('Location: register.php');
  15.       }
  16.       else if($_REQUEST['stdsubmit'])
  17.       {
  18.  
  19.           $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')");
  20.           if(mysql_num_rows($result)>0)
  21.           {
  22.  
  23.               $r=mysql_fetch_array($result);
  24.               if(strcmp(htmlspecialchars_decode($r['std'],ENT_QUOTES),(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0)
  25.               {
  26.                   $_SESSION['stdname']=htmlspecialchars_decode($r['stdname'],ENT_QUOTES);
  27.                   $_SESSION['stdid']=$r['stdid'];
  28.                   unset($_GLOBALS['message']);
  29.                   header('Location: stdwelcome.php');
  30.               }else
  31.           {
  32.               $_GLOBALS['message']="Check Your user name and Password.";
  33.           }
  34.  
  35.           }
  36.           else
  37.           {
  38.               $_GLOBALS['message']="Check Your user name and Password.";
  39.           }
  40.           closedb();
  41.       }
  42.  ?>
  43. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  44.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  45. <html>
  46.   <head>
  47.     <title>Welcome To VITeQUIZ Online Portal</title>
  48.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  49.     <link rel="stylesheet" type="text/css" href="oes.css"/>
  50.   </head>
  51.   <body>
  52.       <?php
  53.  
  54.         if($_GLOBALS['message'])
  55.         {
  56.          echo "<div class=\"message\">".$_GLOBALS['message']."</div>";
  57.         }
  58.       ?>
  59.  
  60.       <div id="container">
  61.  
  62.                 <div class="header">
  63.                 <img style="margin:10px 2px 2px 10px;float:left;" height="80" width="200" src="images/logo.gif" alt="OES"/><h3 class="headtext"> &nbsp;VIT UNIVERSITY </h3><h4 style="color:#ffffff;text-align:center;margin:0 0 5px 5px;"><i>...A place to learn; A chance to grow</i></h4>
  64.             </div>
  65.      <form id="stdloginform" action="index.php" method="post">
  66.       <div class="menubar">
  67.  
  68.        <ul id="menu">
  69.                     <?php if(isset($_SESSION['stdname'])){
  70.                           header('Location: stdwelcome.php');}else{  
  71.  
  72.                         ?>
  73.  
  74.                       <!--  <li><input type="submit" value="Register" name="register" class="subbtn" title="Register"/></li>-->
  75.  
  76.  
  77.                         <?php } ?>
  78.                         <li><div class="aclass"><a href="/VEQ/register.php" title="Click here  to Register">Student Register</a></div></li>
  79.                         <li><div class="aclass"><a href="/VEQ/index.php" title="Click here  to Register">Student Login</a></div></li>
  80.                          <li><div class="aclass"><a href="admin/index.php" title="Click here  to Register">Program Manager Login</a></div></li>
  81.            <li><div class="aclass"><a href="tc/index.php" title="Click here  to Register">Faculty Login</a></div></li>
  82.                     </ul>
  83.  
  84.  
  85.       </div>
  86.       <div class="page">
  87.  
  88.               <table cellpadding="30" cellspacing="10">
  89.               <tr>
  90.                   <td>User Name</td>
  91.                   <td><input type="text" tabindex="1" name="name" value="" size="16" /></td>
  92.  
  93.               </tr>
  94.               <tr>
  95.                   <td>Password</td>
  96.                   <td><input type="password" tabindex="2" name="password" value="" size="16" /></td>
  97.               </tr>
  98.  
  99.               <tr>
  100.                   <td colspan="2">
  101.                       <input type="submit" tabindex="3" value="Log In" name="stdsubmit" class="subbtn" />
  102.                   </td><td></td>
  103.               </tr>
  104.             </table>
  105.  
  106.  
  107.       </div>
  108.        </form>
  109. <?php
  110. include('footer.php');
  111. ?>
  112.           </div>
  113.   </body>
  114. </html>
  115.  
  116.  



Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4.  
  5.  
  6. error_reporting(0);
  7. session_start();
  8.         if(!isset($_SESSION['stdname'])){
  9.             $_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Re-LogIn</a>";
  10.         }
  11.         else if(isset($_REQUEST['logout'])){
  12.                 unset($_SESSION['stdname']);
  13.             $_GLOBALS['message']="You are Loggged Out Successfully.";
  14.             header('Location: index.php');
  15.         }
  16. ?>
  17. <html>
  18.     <head>
  19.         <title>VEQ-DashBoard</title>
  20.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  21.         <link rel="stylesheet" type="text/css" href="oes.css"/>
  22.     </head>
  23.     <body>
  24.         <?php
  25.  
  26.         if($_GLOBALS['message']) {
  27.             echo "<div class=\"message\">".$_GLOBALS['message']."</div>";
  28.         }
  29.         ?>
  30.         <div id="container">
  31.            <div class="header">
  32.                 <img style="margin:10px 2px 2px 10px;float:left;" height="80" width="200" src="images/logo.gif" alt="OES"/><h3 class="headtext"> &nbsp;VIT UNIVERSITY </h3><h4 style="color:#ffffff;text-align:center;margin:0 0 5px 5px;"><i>...A place to learn; A chance to grow</i></h4>
  33.             </div>
  34.             <div class="menubar">
  35.  
  36.                 <form name="stdwelcome" action="stdwelcome.php" method="post">
  37.                     <ul id="menu">
  38.                         <?php if(isset($_SESSION['stdname'])){ ?>
  39.                         <li><input type="submit" value="LogOut" name="logout" class="subbtn" title="Log Out"/></li>
  40.                         <?php } ?>
  41.                     </ul>
  42.                 </form>
  43.             </div>
  44.             <div class="stdpage">
  45.                 <?php if(isset($_SESSION['stdname'])){ ?>
  46.  
  47.  
  48.  
  49.                 <img height="600" width="100%" alt="back" src="images/trans.png" class="btmimg" />
  50.                 <div class="topimg"><BR > <BR > <BR >
  51.                     <p><img height="500" width="600" style="border:none;"  src="images/stdwelcome.jpg" alt="image"  usemap="#oesnav" /></p>
  52.  
  53.                     <map name="oesnav">
  54.                         <area shape="circle" coords="158,118,61" href="viewresult.php" alt="View Results" title="Click to View Results" />
  55.                         <area shape="circle" coords="450,120,70" href="stdtest.php" alt="Take a New Test" title="Take a New Test" />
  56.                         <area shape="circle" coords="300,250,60" href="editprofile.php?edit=edit" alt="Edit Your Profile" title="Click this to Edit Your Profile." />
  57.                         <area shape="circle" coords="150,375,70" href="practicetest.php" alt="Practice Test" title="Click to take a Practice Test" />
  58.                         <area shape="circle" coords="450,375,70" href="resumetest.php" alt="Resume Test" title="Click this to Resume Your Pending Tests." />
  59.                   </map>
  60.                 </div>
  61.                 <?php }?>
  62.  
  63.             </div>
  64.  
  65.            <?php
  66. include('footer.php');
  67. ?>
  68.       </div>
  69.   </body>
  70. </html>
  71.  
Apr 19 '13 #3
johny10151981
1,059 Top Contributor
In your first code, i can see lots of new line has been printed at the beginning of the code. This new line is data for php

If you have already sent data then you cannot redirect using header function. If your warning was enabled you would get an warning, such as header is already sent, or something like that.

So, remove all the unnecessary white space and characters make sure your first character is <? and do not print any data unless all the verification is finished
Apr 19 '13 #4
chirag vora
5 New Member
I removed all unnecessary whitespace and characters..
but still its not working..
its because of i cant implement your second paragraph ..
can u please tell me what to do exactly..
Thanks
Apr 19 '13 #5
johny10151981
1,059 Top Contributor
on first code on line 70, there is a header function called but before that you printed html code, so this function wont work.
Apr 20 '13 #6
chirag vora
5 New Member
So now exactly what to do?? How can i write that code before html code?
Apr 20 '13 #7
johny10151981
1,059 Top Contributor
try this
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.       error_reporting(0);
  3.       session_start();
  4.       include_once 'oesdb.php';
  5.  
  6.       if(isset($_REQUEST['register']))
  7.       {
  8.             header('Location: register.php');
  9.       }
  10.       else if($_REQUEST['stdsubmit'])
  11.       {
  12.  
  13.           $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')");
  14.           if(mysql_num_rows($result)>0)
  15.           {
  16.  
  17.               $r=mysql_fetch_array($result);
  18.               if(strcmp(htmlspecialchars_decode($r['std'],ENT_QUOTES),(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0)
  19.               {
  20.                   $_SESSION['stdname']=htmlspecialchars_decode($r['stdname'],ENT_QUOTES);
  21.                   $_SESSION['stdid']=$r['stdid'];
  22.                   unset($_GLOBALS['message']);
  23.                   header('Location: stdwelcome.php');
  24.               }else
  25.           {
  26.               $_GLOBALS['message']="Check Your user name and Password.";
  27.           }
  28.  
  29.           }
  30.           else
  31.           {
  32.               $_GLOBALS['message']="Check Your user name and Password.";
  33.           }
  34.           closedb();
  35.       }
  36.       if(isset($_SESSION['stdname'])){
  37.                           header('Location: stdwelcome.php');
  38.                           exit;
  39.                           }
  40.  ?>
  41. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  42.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  43. <html>
  44.   <head>
  45.     <title>Welcome To VITeQUIZ Online Portal</title>
  46.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  47.     <link rel="stylesheet" type="text/css" href="oes.css"/>
  48.   </head>
  49.   <body>
  50.       <?php
  51.  
  52.         if($_GLOBALS['message'])
  53.         {
  54.          echo "<div class=\"message\">".$_GLOBALS['message']."</div>";
  55.         }
  56.       ?>
  57.  
  58.       <div id="container">
  59.  
  60.                 <div class="header">
  61.                 <img style="margin:10px 2px 2px 10px;float:left;" height="80" width="200" src="images/logo.gif" alt="OES"/><h3 class="headtext"> &nbsp;VIT UNIVERSITY </h3><h4 style="color:#ffffff;text-align:center;margin:0 0 5px 5px;"><i>...A place to learn; A chance to grow</i></h4>
  62.             </div>
  63.      <form id="stdloginform" action="index.php" method="post">
  64.       <div class="menubar">
  65.  
  66.        <ul id="menu">
  67.  
  68.                       <!--  <li><input type="submit" value="Register" name="register" class="subbtn" title="Register"/></li>-->
  69.                         <li><div class="aclass"><a href="/VEQ/register.php" title="Click here  to Register">Student Register</a></div></li>
  70.                         <li><div class="aclass"><a href="/VEQ/index.php" title="Click here  to Register">Student Login</a></div></li>
  71.                          <li><div class="aclass"><a href="admin/index.php" title="Click here  to Register">Program Manager Login</a></div></li>
  72.            <li><div class="aclass"><a href="tc/index.php" title="Click here  to Register">Faculty Login</a></div></li>
  73.                     </ul>
  74.  
  75.  
  76.       </div>
  77.       <div class="page">
  78.  
  79.               <table cellpadding="30" cellspacing="10">
  80.               <tr>
  81.                   <td>User Name</td>
  82.                   <td><input type="text" tabindex="1" name="name" value="" size="16" /></td>
  83.  
  84.               </tr>
  85.               <tr>
  86.                   <td>Password</td>
  87.                   <td><input type="password" tabindex="2" name="password" value="" size="16" /></td>
  88.               </tr>
  89.  
  90.               <tr>
  91.                   <td colspan="2">
  92.                       <input type="submit" tabindex="3" value="Log In" name="stdsubmit" class="subbtn" />
  93.                   </td><td></td>
  94.               </tr>
  95.             </table>
  96.  
  97.  
  98.       </div>
  99.        </form>
  100. <?php
  101. include('footer.php');
  102. ?>
  103.           </div>
  104.   </body>
  105. </html>
  106.  
Apr 20 '13 #8
chirag vora
5 New Member
Thanks...but it displays a blank page
Apr 20 '13 #9
Bernybon
1 New Member
@chirag vora
Did you find a solution? It's doing the same thing for me!
Sep 29 '13 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2264
by: Jeff Alu | last post by:
Hi, I'm moving a website to a new location for a friend of mine. The old site http://www.infomercialavails.com Is working fine. However, the php files at the new location seem to be having...
3
2202
by: Jamie Burns | last post by:
Can anyone tell me how I can modify the Server String header? At the moment it is: Server: Apache/1.3.27 (Unix) PHP/4.3.3 But I would like it to become: Server: Apache/1.3.27 (Unix)...
11
2305
by: pinbot | last post by:
As far as I know, http headers should not work after content has been written. This is how my production box is working, but for some reason on my dev box I was getting away with a location header...
0
357
by: John Crowley | last post by:
I keep running into this over and over again... I want a block server control that renders a header and footer, and child controls in between. But I don't want a templated control, for the...
2
1588
by: Nicholas | last post by:
Here is the issue: 1. I would like to create an ASP.Net/C# control to append a dynamic header and footer to **every** web page (depending on the page the content of each will vary). I can...
0
1123
by: kapil singhal via DotNetMonster.com | last post by:
I have a C#/.Net 1.1 client talking to a Java based web service. I want to make it a stateful service and i found this solution only: 1. the instance IDs are transferred in the SOAP headers. 2....
0
837
by: Kory | last post by:
HI, I'm using WSE 2.0 SP3 on both client and server. I'm also using .NET Web services for both client and server. On the server side, I have trace turned on and I see two messages for each...
1
1986
by: Bob | last post by:
Hi, I have created a webrequest that is failing at the server because it has Encoding =UTF-16 in the header. The server people want me to remove the entry altogether. I can't see where I have...
2
2296
by: Petri Savolainen | last post by:
Hello, Is there a way to get at the "Received" header(s) or is there something in imaplib or imap server implementations that hides these? If not, what IMAP FETCH command should be used? I've...
14
6338
by: freefony | last post by:
please help me with this <?php $sc=$_POST; $name=$_POST; $emp=$_POST; include("conn.php"); $qry="select employer from corper"; $rst=mysql_query($qry) or die(mysql_error()); <select...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7043
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6737
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6921
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.