0

Helllo I am getting Warning: Cannot modify header information - headers already sent by error on header("location: sucessful_registration.php"); line
please help me how can i fix it

function NewUser()
{
    $full_name = $_POST['full_name'];
    $user_name = $_POST['user_name'];
    $password = $_POST['password']; 
    $email_address = $_POST['email_address'];
    $phone = $_POST['phone'];
    $address = $_POST['address'];
    $city = $_POST['city']; 
    $zip = $_POST['zip'];
    $state = $_POST['state'];
    $country = $_POST['default_country'];
    $member_id = $_POST['member_id'];
    $card_csv = $_POST['card_csv']; 
    $activation_new = "0";
    $query = "INSERT INTO user_registration (full_name,username,password,email,phone,address,city,zip,state_province,country,member_id,member_csv,activation) VALUES ('$full_name','$user_name','$password','$email_address','$phone','$address','$city','$zip','$state','$country','$member_id','$card_csv','$activation_new')";
    $data = mysql_query ($query)or die(mysql_error());
    if($data)
    {
                header("location: sucessful_registration.php");
    }
}
newuser();

    } 
3
Contributors
5
Replies
14
Views
3 Years
Discussion Span
Last Post by pritaeas
0

Make sure there is nothing outputted before calling header(). I'm positive you missed something, since you're not showing all your code. It could be as simple as a space somewhere.

0

here is the complete code

<?php
ob_start();
include('connect.php');
if (isset($_POST['formsubmitted'])) {

    $error = array();//Declare An Array to store any error message

    if (empty($_POST['full_name'])) {
        $error[] = 'Please Enter your full name';
    } else {

        if (preg_match("/^[a-z0-9 .\-]+$/i", $_POST['full_name'])) {
           //regular expression for text inputs
            $full_name = $_POST['full_name'];
        } else {
             $error[] = 'Full name is invalid';
        }


    }



        if (empty($_POST['user_name'])) {
        $error[] = 'Please enter a username';
    } else {

        $user_name = $_POST['user_name'];       
    }


    if (empty($_POST['password'])) {
        $error[] = 'Please enter a password';
    } else {

        $password = $_POST['password'];     
    }


    if (empty($_POST['phone'])) {
        $error[] = 'Please enter a phone number';
    } else {

        $phone = $_POST['phone'];       
    }



    if (empty($_POST['address'])) {
        $error[] = 'Please enter a valid address';
    } else {

        $address = $_POST['address'];       
    }



    if (empty($_POST['city'])) {
        $error[] = 'Please enter a valid address';
    } else {

        $city = $_POST['city'];     
    }



    if (empty($_POST['zip'])) {
        $error[] = 'Please enter Zip/Postal code';
    } else {

        $zip = $_POST['zip'];       
    }


    if (empty($_POST['state'])) {
        $error[] = 'Please enter State/Province';
    } else {

        $state = $_POST['state'];       
    }



    if (empty($_POST['default_country'])) {
        $error[] = 'Select your country';
    } else {

        $county = $_POST['default_country'];        
    }




    if (empty($_POST['card_csv'])) {
        $error[] = 'Please enter card CSV';
    } else {

        $card_csv = $_POST['card_csv'];     
    }



    if (empty($_POST['email_address'])) {
        $error['email_address'] = 'Please Enter your Email ';
    } else {


        if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['email_address'])) {
           //regular expression for email validation
            $email_address = $_POST['email_address'];
        } else {
             $error[] = 'Your Email Address is invalid  ';
        }


    }


    if (empty($_POST['member_id'])) {
        $error[] = 'Please enter a member id/card number';
    } else {
        $member_card = $_POST['member_id']; 

        $query = "SELECT * FROM `card_numbers` WHERE gcard_number='$member_card'";
        $result = mysql_query($query) or die(mysql_error());

        $count = mysql_num_rows($result);
//3.1.2
        if ($count == 1){
            $member_id = $member_card;
            }else{
                //3.1.3 

            $error[] = "Please enter a valid member id/card number";

            }
        }


    if (empty($error)) //send to Database if there's no error '

    { // If everything's OK...

function NewUser()
{
    $full_name = $_POST['full_name'];
    $user_name = $_POST['user_name'];
    $password = $_POST['password']; 
    $email_address = $_POST['email_address'];
    $phone = $_POST['phone'];
    $address = $_POST['address'];
    $city = $_POST['city']; 
    $zip = $_POST['zip'];
    $state = $_POST['state'];
    $country = $_POST['default_country'];
    $member_id = $_POST['member_id'];
    $card_csv = $_POST['card_csv']; 
    $activation_new = "0";
    $query = "INSERT INTO user_registration (full_name,username,password,email,phone,address,city,zip,state_province,country,member_id,member_csv,activation) VALUES ('$full_name','$user_name','$password','$email_address','$phone','$address','$city','$zip','$state','$country','$member_id','$card_csv','$activation_new')";
    $data = mysql_query ($query)or die(mysql_error());
    if($data)
    {
                header("location: sucessful_registration.php");
    }
}
newuser();

    } 


    else {//If the "error" array contains error msg , display them


$error_show =  '';
        foreach ($error as $key => $values) {

      $error_show .='   <li>'. $values.'</li>';     




        }
$error_display = "<div class='errormsgbox'> <ol>".$error_show."</ol></div>";

    }


 }// End of the main Submit conditional.


?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.