472,331 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 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 6168
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,...
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 =...
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...
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...
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,...
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...
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...
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...
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,...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.