0

I have the following codes written:

        <html>

    <head>
<?php 
    if (isset($_POST['report'])) 
{
$name = $_POST['Name'] ;
$email = $_POST['Email'] ;
 header('Location: subscriber.php?key='.$name.'?key1='.$email);
}
    ?>

     <script type="text/javascript" src="assets/bootstrap/js/jquery-1.9.1.min.js"></script>    
 <script type="text/javascript" src="assets/bootstrap/js/bootstrap.min.js"></script>
 <link rel="stylesheet" href="inner.css" type="text/css" />

 <style>
 div#copyright {
float: left;
width: 100%;
background: #000;
color: #fff;
padding: 15px 15px;
}

.c_right {
float: left;
width: 50%;
text-align: left;
}

#copyright li {
float: left;
width: 30px;
margin-right: 10px;
list-style:none !important;
}

.c_left {
float: right;
}

 </style>
 </head>
 <body>
    <div id="footer">
        <div class="container-fluid"> 
            <div class="row">
                <div class="col-xs-6 col-sm-3">
                <h3>Quick Links</h3>
                    <div id="footnav1">
                        <ul>
                          <li><a href="#">About Us</a></li>
          <li><a href="#">FAQs</a></li>
          <li><a href="#">Sitemap</a></li>
          <li><a href="#">Contact Us</a></li>
          <li><a href="#">Term & Conditions</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3">
                <h3>Quick Links</h3>
                    <div id="footnav2">
                    <ul>
                      <li><a href="#">Privacy & Cookie Policy</a></li>
                      <li><a href="#">Megahung Blog</a></li>
                      <li><a href="#">Donate Cashback</a></li>
                      <li><a href="#">How Megahung Works</a></li>
                      <li><a href="#">Why Choose Megahunt?</a></li>

                    </ul>
              </div>
                </div>



         <div class="col-xs-6 col-sm-3">
         <h3>Quick Links</h3>
         <div id="footnav3">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Services</a></li>
          <li><a href="#">Catalog</a></li>
          <li><a href="#">Blog</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
</div>
</div>

    <div class="col-xs-6 col-sm-3">
    <h3>Newsletter</h3>

         <div id="footnav4" class="nl_subscribe">
        <form method="post">
            <input type="text" name="Name" size="20" class="email_css" placeholder="Enter your name...">
            <input type="text" name="Email" size="20" class="email_css" placeholder="Enter your email...">

            <input type="submit" name="report" value="Subscribe" class="btn btn-subscribe"/>
            </form>
</div>
</div>  

    </div>
  </div>
   </div>

   <div id="copyright">
            <div class="c_right"><h3 class="cp">Copyright © 2015 <span style="color:#ff6803">Megahunt</span>. All Rights Reserved.</h3></div>
            <div class="c_left">
            <ul class="social">
                <li><a href="https://www.facebook.com/megahunt.in" target="_blank"><img src="images/facebook.png"></a></li>
                <li><a href="https://twitter.com/Megahunt1" target="_blank"><img src="images/twitter.png"></a></li>
                <li><a href="#"><img src="images/linkedin.png"></a></li>
                <li><a href="#"><img src="images/google.png"></a></li>
                <li><a href="#"><img src="images/instagram.png"></a></li>
                <li><a href="http://www.pinterest.com/pin/create/button/" target="_blank"><img src="images/pinterest.png"></a></li>

            <ul>
            </div>
    </div>

    </body>

    </html>

Now when I click on the Submit button the page is loaded but its actually loaded in the same page not going to subscriber.php page.

I have placed the php block before the html also but still the same issue persists.

Can anyone help me with this issue please.

user3305327
  • 897
  • 4
  • 18
  • 34
  • 1
    you're outputting before header. – Funk Forty Niner Jun 06 '15 at 18:32
  • @Fred-ii-...can you please help me a li'l more could not get much help with the other thread – user3305327 Jun 06 '15 at 18:37
  • place your php above html – Funk Forty Niner Jun 06 '15 at 18:45
  • @Fred-ii-...I did so but still its not working...should i post the full code here? – user3305327 Jun 06 '15 at 19:10
  • @Fred-ii- i have shared the whole code and the php is above the html but still its not working...please guide me – user3305327 Jun 06 '15 at 19:21
  • @Fred-ii-...please help me with the code...the link you have shared is not very handy for me... – user3305327 Jun 06 '15 at 20:02
  • 1
    you're still outputting before header. Please read the page with the link that the question has been closed with. Your answers are in there. I don't mean to sound rude here and it's not my intention to, but Stack didn't give the option to close questions for nothing. This kind of question gets asked often because of that; outputting before header. I told you what to do earlier, but then you changed your question/code completely. HTML counts as "output" as outlined in the link. The person who voted to reopen, doesn't understand Stack's rules. It's not my rule, it's Stack's. – Funk Forty Niner Jun 06 '15 at 21:01
  • @Fred-ii-...am sorry for not understanding Stack's rule here.. – user3305327 Jun 07 '15 at 07:17
  • @Fred-ii-...through that thread I could not understand what to do anyway lets put my problem unresolved...thanks – user3305327 Jun 07 '15 at 07:18
  • I don't normally do this and it goes against Stack's rules; but I've reopened the question in order to show you in a graphical way using your code, how to use your code. Consult my answer below. – Funk Forty Niner Jun 07 '15 at 13:05

1 Answers1

0

I reopened the question since the OP does not seem to understand what the duplicate question link's instructions are.

As I said in comments, you are outputting before header, and you're not seeing this warning because your system most likely does not have error reporting enabled. Consult my footnotes about this.

Modify your code to this (rest of code omitted) and exit added.

Sidenote: Make sure there are no spaces before your opening <?php tag and that your file does not contain a byte order mark. Absolutely NOTHING should be above your opening PHP, no includes etc.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

    if (isset($_POST['report'])) 
{
$name = $_POST['Name'] ;
$email = $_POST['Email'] ;
 header('Location: subscriber.php?key='.$name.'?key1='.$email);
 exit;
}
    ?>

       <html>

<head>

     <script type="text/javascript" src="assets/bootstrap/js/jquery-1.9.1.min.js"></script>    
 <script type="text/javascript" src="assets/bootstrap/js/bootstrap.min.js"></script>
 <link rel="stylesheet" href="inner.css" type="text/css" />

...followed by the rest of your code.

  • Also make sure that your subscriber.php does not also have anything that will cause an output before header.

Footnotes:

Add error reporting to the top of your file(s) which will help find errors.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code

Sidenote: Error reporting should only be done in staging, and never production.

  • You should also use a conditional !empty() for your inputs.
Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141