2

I have a signup page which is working fine on my localhost. When an user submits the form it will got the action page and process the signup and after successful submission it will redirect user to a confirmation page.

But in server when a user submits the form it goes to the action page and just gets reloaded again and again but nothing happens.

I am working with php.

If anyone of this forum already faced this type of scenario or know why this is happening please help me. I have to deliver the project today after uploading the project on server this is happening.

code:

        require_once('conn.php');

            $exp1 = $_POST["exp1"];             $exp2 = $_POST["exp2"];
            $expdate = $exp1 .  "/" . $exp2; 
            if ($_POST['hwno'] != 'BYOD') { 
                $shipadd = $_POST["shipadd1"] . " " . $_POST["shipadd2"] . ", " . $_POST["shipadd3"] . " " . $_POST["shipadd4"] . " " . $_POST["shipadd5"]; 
            }

            $shipname = $_POST["fname"] . " " . $_POST["lname"];
            if($_POST["type"] != "satellite") {
                $location = $_POST["dbcountry"] . " - " . $_POST["dbcity"] . ", " . $_POST["dbstate"]; 
                $location2 = $_POST["dbcountry2"] . " - " . $_POST["dbcity2"] . ", " . $_POST["dbstate2"];
                $lnum = $_POST["dblocalnum"];
                $lnum2 = $_POST["dblocalnum2"];
            } else {
                $location = "none"; 
                $location2 = "none";
                $lnum = "none";
                $lnum2 = "none";
            }   

            $sfname = $_POST["fname"];
            $slname = $_POST["lname"];
            $sstreet = $_POST["street"];
            $scity = $_POST["city"];

            $sgtotal = $_POST["gtotal"];

            if ($_POST['hwno'] != 'BYOD') {
                $sshipmethod = $_POST["shipmethod"];
                $query = "query here";
            }
            else {
                $query = "query here";
            }

        $to = "email here";
        $subject = "subject";
        $message = "message hre";
                $confirmationMail = mail ($to, $subject, $message, $from);
                if(!$confirmationMail) {
                    echo "Something went wrong. Please try again";
                }
               $returnTo = "thankyou.php";
               //echo $returnTo;
              }
             } 
             else {
              echo "error writing to database";
             }   
            ?>
<html>
<head>
<script language="JavaScript">
document.location = "<?php echo $returnTo; ?>";
</script></head>

Thanks in advance

hakre
  • 193,403
  • 52
  • 435
  • 836
user1559230
  • 2,790
  • 5
  • 26
  • 32
  • @deadlock sample code added with the post. – user1559230 Mar 17 '13 at 12:54
  • After `$returnTo = "thankyou.php";` try to add `header("Location: $returnTo");` and remove that HTML code on the bottom. – HamZa Mar 17 '13 at 12:56
  • it seems ` } } else { echo "error writing to database"; } ` is extra code...is a typo? – Amir Mar 17 '13 at 13:05
  • gives this warning Warning: Cannot modify header information - headers already sent by (output started at /home5/nassauis/public_html/sunisp/checkout2.php:1) in /home5/nassauis/public_html/sunisp/checkout2.php on line 215 – user1559230 Mar 17 '13 at 13:10
  • @user1559230 that error is covered in [this post](http://stackoverflow.com/q/8028957/1401975) – HamZa Mar 17 '13 at 13:16
  • @HamZaDzCyberDeV So because I was using JavaScript for url redirect that why page was reloading continuously ? – ehp Mar 17 '13 at 13:26
  • @ehp i don't know exactly what's going on his page since he only provided the source of the action page. So i just though of fixing that issue first, i hope you agree that it's better to redirect on the first place with PHP ? – HamZa Mar 17 '13 at 13:38
  • Yes. I agree with. But I also wanted to know the reason behind it. – ehp Mar 17 '13 at 13:44
  • @user1559230 could you provide the relevant code of the signup page ? – HamZa Mar 17 '13 at 15:09
  • @HamZaDzCyberDeV Sorry for late reply. My form page is just a html form with some input fileds. This is not showing on my localhost but showing on server. I have commented all echo but still I am having the warning message. – user1559230 Mar 19 '13 at 10:22
  • Why are you using JS at all to redirect? Just use a PHP `header`. – Jared Eitnier Apr 19 '13 at 02:24

1 Answers1

0

As per my understood, The code you've created is supposed to reload. The javascript code is responsible for the redirection. Make sure your javascript is not getting an error. See if the result code after the submit will be as you expect. If everything is ok try to run thankyou.php manually. Something like

http://domain/thankyou.php.
Jose Areas
  • 719
  • 3
  • 11