1

I have written a sign up page in php, everything is ok and values are being saved in database but its not opening next page after the values are saved into the database here is my code. Kindly check what might be the issue.

<?php
if (isset($_POST['button']))
{

    $st_name=$_POST['st_name'];
    $f_name=$_POST['f_name'];
    $email=$_POST['email'];
    $re_email=$_POST['re_email'];
    $pass=$_POST['pass'];
    $re_pass=$_POST['re_pass'];
    $phone=$_POST['phone'];
    $mobile=$_POST['mobile'];
    $skype=$_POST['skype'];
    $quali=$_POST['quali'];
    $country=$_POST['country'];
    $city=$_POST['city'];
    $date=$_POST['date'];
    $g=$_POST['g'];
    $image="back.jpg";
    if($email!=$re_email){
    echo "<script>window.open('sign_up.php?error=email_error','_self')</script>";
    }
    else if($pass!=$re_pass){
    echo "<script>window.open('sign_up.php?error=pass_error','_self')</script>";

    }
    else{


        $que="insert into sign_up(st_name,f_name,email,re_email,pass,re_pass,phone,mobile,skype,quali,country,city,date,gender,image) 
        values ('$st_name','$f_name','$email','$re_email','$pass','$re_pass','$phone','$mobile','$skype','$quali','$country','$city','$date','$g','$image')";
        if(mysql_query($que))
        {
        $_SESSION['email']=$email;
        $_SESSION['pass']=$pass;

            header("location: index.php");


        }
        else{
        mysql_error();

        }
        }
}

?>
Parthapratim Neog
  • 4,352
  • 6
  • 43
  • 79
Imran Iqbal
  • 478
  • 5
  • 15

4 Answers4

1

The issue is that you are outputting something before your call to the header() function. You will need to ensure that there is nothing in the HTML output (not even whitespace) before your call to that function.

Tash Pemhiwa
  • 7,590
  • 4
  • 45
  • 49
0

Simply typo

Change

header("location: index.php");

To

header("Location: index.php");

Pupil
  • 23,834
  • 6
  • 44
  • 66
  • not working, now showing this error Warning: Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\school\sign_up.php:423) in E:\xampp\htdocs\school\sign_up.php on line 459 – Imran Iqbal Oct 15 '15 at 16:22
  • Add ob_start ( ) in the start. – Pupil Oct 15 '15 at 16:25
  • it's working offline but online not working even online showing this error Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/daremuslim/public_html/sign_up.php:2) in /home/daremuslim/public_html/sign_up.php on line 3 you can check error at here http://daremuslim.com/sign_up.php – Imran Iqbal Oct 15 '15 at 16:53
0

Not sure if this makes a difference or not but header("location: index.php"); needs the L capitalized on Location header("Location: index.php");

jagler
  • 185
  • 1
  • 6
  • Try this since it looks like headers are already posted`header( "refresh:1;url=index.php" ); ` – jagler Oct 15 '15 at 16:36
0

If the header isn't being sent then that means that the condition is not evaluating to true. SESSION variables aren't saved when you call the location header because the script hasn't finished running before leaving the page. To save the variables before sending a location header use session_write_close()