473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

header working on localhost but not working online

please help me with this
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $sc=$_POST['sc'];
  3. $name=$_POST['name'];
  4. $emp=$_POST['ppa'];
  5. include("conn.php");
  6. $qry="select employer from corper";
  7. $rst=mysql_query($qry) or die(mysql_error());
  8. <select name="ppa" class="select">
  9. <option value=""></option>
  10.  <?php while($row=mysql_fetch_assoc($rst)){
  11. echo "<option value='".$row['employer']."'>".$row['employer']."</option>";
  12. }
  13. if (isset($_POST['rvt']))
  14. {
  15. if(isset($_POST['sc']) && ($_POST['sc']!=''))
  16. {
  17. header("Location:http://www.nyscfct.org/detail.php?sc=$sc");
  18.  }
  19. else if(isset($_POST['name']) && ($_POST['name']!='')){
  20. header("Location:http://www.nyscfct.org/searchresult.php?name=$name");
  21. }
  22.  elseif(isset($_POST['ppa']) && ($_POST['ppa']!=''))
  23. {
  24. header("Location:searchresult.php?emp=$emp");
  25.                                              }elseif(($_POST['sc']='') && ($_POST['name']='') && ($_POST['ppa']=''))
  26. {
  27. die('Please go back <a href="index.php">Home</a> fill in atleast one search criterea');
  28. }
  29. }
  30. ?>
it works on my localhost and even redirect me to the pages online but from my index online it does not work please help its urgent.
Aug 3 '09 #1
14 6326
anon538
23
The code you have provided is without error, except for the random html floating in the middle of it, though I think that was just an accident when you posted it.
However, I think you may have two issues:
1. You switched from localhost to an actual server. Has your database information (contents, connection data) been preserved?
2. You coded the giant if/else if block without an else case. If $_POST['rvt'] was never set, your page would never redirect you. Check to make sure this is working by adding an else block at the end of your code (else echo "rvt not set";) If $_POST['rvt'] is set, your problem may be a logical one in the set of elseif blocks. If none if them eval to true, you may similarly be staring at a blank page. See if this is the problem by changing your last elseif to an else. If you get the die message, it means that either your POST variables are not all set, or your logic is wrong.

~anon
Aug 3 '09 #2
i have done that its still not working i thinking the logic is fine its working perfectly on my local mechine its just the online thing
Aug 4 '09 #3
zorgi
431 Expert 256MB
Do you get any errors?
Aug 4 '09 #4
no i didnt get errors its just takes me back to the index page ignoring the whole header lines
Aug 4 '09 #5
zorgi
431 Expert 256MB
Than I would have to agree with anon538.

Try Changing your

if (isset($_POST['rvt'])) on line 13 to if (true)

and also

if(isset($_POST['sc']) && ($_POST['sc']!='')) on line 15 to if (true)


if you get redirected than your logic is wrong.
Aug 4 '09 #6
no didnt work do i need to configure the htaccess for php header to work ? or what alternatives do i have to this
Aug 4 '09 #7
zorgi
431 Expert 256MB
Is the code you gave us exact copy or there are some differences?
Aug 4 '09 #8
ok i got better here is the code now but its giving me this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/nyscfct/public_html/conn.php:17) in /home/nyscfct/public_html/index.php on line 21
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $sc=$_POST['sc'];
  3. $name=$_POST['name'];
  4. $emp=$_POST['ppa'];
  5. include("conn.php");
  6. $qry="select employer from corper";
  7. $rst=mysql_query($qry) or die(mysql_error());
  8. if (isset($_POST['rvt']))
  9. {
  10. if(isset($_POST['name']) && ($_POST['name']!=''))
  11. {
  12. header("Location:http://www.nyscfct.org/detail.php?sc=$sc");
  13.  }
  14. else if(isset($_POST['name']) && ($_POST['name']!=''))
  15. {
  16. header("Location:http://www.nyscfct.org/searchresult.php?name=$name");
  17.  
  18.  }
  19.                                      elseif(isset($_POST['ppa']) && ($_POST['ppa']!='')){
  20.  
  21.                                             header("Location:searchresult.php?emp=$emp");
  22.  
  23.                                      }elseif(($_POST['sc']='') && ($_POST['name']='') && ($_POST['ppa']='')){
  24.                                          die('Please go back <a href="index.php">Home</a> fill in atleast one search criterea');
  25.                                     }
  26.                                 }
  27.  
  28.  
  29.  
  30. ?>
  31.  
Aug 4 '09 #9
zorgi
431 Expert 256MB
that means that within your conn.php that you included on line 5 something has already been outputted to the browser.

header() must be called before any actual output is sent

http://hr.php.net/manual/en/function.header.php
Aug 4 '09 #10
i changed it to this
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $sc=$_POST['sc'];
  3. if (isset($_POST['rvt'])){
  4.                                         if(isset($_POST['sc']) && ($_POST['sc']!='')){
  5.  
  6.                                             header("Location:http://www.nyscfct.org/
  7.                                             detail.php?sc=$sc");
  8.                                        }
  9.                                      else if(isset($_POST['name']) && ($_POST['name']!='')){
  10.                                          header("Location:http://www.nyscfct.org/searchresult.php?name=$name");
  11.  
  12.                                      }
  13.                                      elseif(isset($_POST['ppa']) && ($_POST['ppa']!='')){
  14.  
  15.                                             header("Location:searchresult.php?emp=$emp");
  16.  
  17.                                      }elseif(($_POST['sc']='') && ($_POST['name']='') && ($_POST['ppa']='')){
  18.                                          die('Please go back <a href="index.php">Home</a> fill in atleast one search criterea');
  19.                                     }
  20.                                 }
  21. $name=$_POST['name'];
  22. $emp=$_POST['ppa'];
  23. include("conn.php");
  24. $qry="select employer from corper";
  25. $rst=mysql_query($qry) or die(mysql_error());
  26.  
  27.  
  28.  
  29.  
  30. ?>
  31.  
the error is gone but the conditions re not working properly the first(if(isset($_Post['sc']))) is not navigating while the other two re going to detail.php instead of searchresult.php
Aug 4 '09 #11
zorgi
431 Expert 256MB
@freefony
So redirection works but the logic doesn't.
Aug 4 '09 #12
now i have this but
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $sc=$_POST['sc'];
  3. $name=$_POST['name'];
  4. $emp=$_POST['ppa'];
  5. if (isset($_POST['rvt']))
  6. {
  7. if(isset($_POST['name']) && ($_POST['name']!=''))
  8. {
  9. header("Location:http://www.nyscfct.org/detail.php?sc=$sc");
  10.  }
  11. else if(isset($_POST['name']) && ($_POST['name']!=''))
  12. {
  13. header("Location:http://www.nyscfct.org/searchresult.php?name=$name");
  14.  
  15.  }
  16.                                      elseif(isset($_POST['ppa']) && ($_POST['ppa']!='')){
  17.  
  18.                                             header("Location:searchresult.php?emp=$emp");
  19.  
  20.                                      }elseif(($_POST['sc']='') && ($_POST['name']='') && ($_POST['ppa']='')){
  21.                                          die('Please go back <a href="index.php">Home</a> fill in atleast one search criterea');
  22.                                     }
  23.                                 }
  24.  
  25.  
  26.  
  27. include("conn.php");
  28. $qry="select employer from corper";
  29. $rst=mysql_query($qry) or die(mysql_error());
  30.  
  31. ?>
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  33. <html xmlns="http://www.w3.org/1999/xhtml">
  34. <head>
  35. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  36. <title>NYSC FCT</title>
  37. <style type="text/css">
  38. <!--
  39.  
  40. .select{width:150px}
  41. .link{ color:#FFFFFF; text-decoration:none}
  42. .notice{color:#FF0000; font-size:16px; font-family:"Bradley Hand ITC"; text-decoration:underline}
  43. -->
  44. </style></head>
  45.  
  46. <body>
  47. <table width="100%" bgcolor="#003300">
  48. <tr>
  49. <td align="center">
  50. <br /><br /><br />
  51. <form method="post" action="index.php">
  52. <table width="70%" border="0" cellspacing="10" bordercolor="#CCCCCC" bgcolor="#FFFFFF">
  53.     <tr>
  54.         <td colspan="2">
  55.             <table width="100%" border="1" bordercolor="#99FF00" cellpadding="0" cellspacing="0">
  56.                 <tr>
  57.                     <td>
  58.                         <img src="new.png" />
  59.                     </td>
  60.                 </tr>
  61.                 <tr>
  62.                     <td bgcolor="#99CC00">
  63.                         <table width="100%" border="0">
  64.                         <tr>
  65.                             <td width="6%"><a href="index.php" class="link">Home</a></td>
  66.                             <td width="15%"><a href="ppa.php" class="link"> Primary Assignment</a></td>
  67.                             <td width="7%"><a href="ppa.php" class="link">News</a></td>
  68.                             <td width="18%"><a href="ppa.php" class="link">Community Development</a></td>
  69.                             <td width="11%"><a href="ppa.php" class="link">Abuja Corper</a></td>
  70.                             <td width="7%"><a href="ppa.php" class="link">Gallery</a></td>
  71.                             <td width="8%"><a href="ppa.php" class="link">YearBook</a></td>
  72.                             <td width="11%"><a href="ppa.php" class="link">Blogs/FAQ</a></td>
  73.                           <td width="17%"><input type="text" name="search" value="Search" /></td>
  74.                         </tr>
  75.                         </table>
  76.                     </td>
  77.                 </tr>
  78.             </table>
  79.         </td>
  80.     </tr>
  81.     <tr>
  82.         <td background="info.png" width="60%" rowspan="2">
  83.         <br />
  84.             <table width="100%" border="0">
  85.                 <tr>
  86.                     <td align="center" valign="middle">
  87.                         <br /><h4 class="notice">NOTICE TO ALL EMPLOYERS!</h4>
  88.                         <p><b>Please Kindly verify the status
  89.                          of corps members posted to your<br />
  90.                         organisation before the issuance of acceptance
  91.                         letter.</b><br />
  92.                     <label>For further information please call:07032225490,08025940835 or mail us at info@nyscfct.org</label>
  93.               </p>
  94.  
  95.                     </td>
  96.  
  97.                 </tr>
  98.             </table>
  99.  
  100.         </td>
  101.         <td>
  102.         <table border="0" width="100%" background="search.png" >
  103.                 <tr>
  104.                     <td colspan="2" align="center" bgcolor="#99CC00">
  105.                         <label>CORP MEMBER'S INFORMATION</label>
  106.                     </td>
  107.                 </tr>
  108.                 <tr>
  109.                     <td>
  110.                         <label>Search By Statecode</label>
  111.                     </td>
  112.                     <td align="right">
  113.                         <input type="text" name="sc"  />
  114.                     </td>
  115.                 </tr>
  116.                 <tr>
  117.                     <td>
  118.                         <label>Search By Name</label>
  119.                     </td>
  120.                     <td align="right">
  121.                         <input type="text" name="name" />
  122.                     </td>
  123.                 </tr>
  124.                 <tr>
  125.                     <td>
  126.                         <label>Search By place of primary Assignment</label>
  127.                     </td>
  128.                     <td align="right">
  129.                         <select name="ppa" class="select">
  130.                         <option value=""></option>
  131.                          <?php while($row=mysql_fetch_assoc($rst)){
  132.                                     echo "<option value='".$row['employer']."'>".$row['employer']."</option>";
  133.                                     }
  134.  
  135.                                 ?>
  136.                       </select>
  137.                     </td>
  138.                 </tr>
  139.                 <tr>
  140.                     <td align="center" colspan="2">
  141.                         <input type="submit" name="rvt" value="Get Info"/>
  142.                     </td>
  143.                 </tr>
  144.           </table>    
  145.         </td>
  146.     </tr>        
  147. </table>
  148. </form>
  149. </td>
  150. </tr>
  151. <tr>
  152.     <td align="center">
  153.         <table width="74%" border="0" bgcolor="#FFFFFF">
  154.             <tr>
  155.  
  156.  
  157.                 <td align="center">
  158.                 NYSC FCT 2009&copy; All rights reserved                </td>
  159.  
  160.             </tr>
  161.         </table>
  162. <br />
  163. <br />
  164. </td>
  165. </tr>
  166. </table>    
  167. </body>
  168. </html>
  169.  
but the $_post varibles are not catching the values of my textboxes
Aug 4 '09 #13
zorgi
431 Expert 256MB
Try this:

Expand|Select|Wrap|Line Numbers
  1. $sc=$_POST['sc'];
  2. $name=$_POST['name'];
  3. $emp=$_POST['ppa'];
  4. if (isset($_POST['rvt'])){
  5.     if(!empty($_POST['sc'])){
  6.         header("Location:http://www.nyscfct.org/detail.php?sc=$sc");
  7.     }elseif(!empty($_POST['name'])){
  8.          header("Location:http://www.nyscfct.org/searchresult.php?name=$name");
  9.     }elseif(!empty($_POST['ppa'])){
  10.          header("Location:searchresult.php?emp=$emp");
  11.     }else{
  12.         die('Please go back <a href="index.php">Home</a> fill in atleast one search criterea');
  13.     }
  14. }
  15.  
Aug 4 '09 #14
hey ! am not gay but i must say i love you its working perfectly now
thanks a million
Aug 5 '09 #15

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

Similar topics

6
by: Jason Collins | last post by:
There seems to be an inconsistency (bug?) in the way the Set-Cookie header is handled by the WebHeaderCollection. That is, the values of Set-Cookie, when an Expires is specified, contain the ","...
3
by: Ben | last post by:
Hi, I'm wondering how can i change the datagrid header text at runtime so that it keeps the sorting enabled? I can do; e.Item.Cells.Text = "foo"; But then foo is the text of the table cell...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
20
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
I was executing the steps given in http://suppor.microsoft.com/kb/308359 for testing a sample web service application. However, the following line gives a compilation error: localhost.Service1...
3
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
2
by: Steve | last post by:
Hi All I am using VB.net 2005 windows forms I use the Datagridview.cellformatting event to change the colours of individual cells as required and all works fine How can I do the same for...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.