user2682649
user2682649

Reputation: 1

header working on localhost but not working on a live server

wonder if anyone could help. my problem is that the site works on localhost but when I ftp it to a live server the header() doesn't redirect them to (in this case) a thank you page, the data how ever is recorded in the database.

PHP code:

<?php
    if (isset($_POST['submit'])) {
    $connect_error = 'Sorry, Connection problems.';
    mysql_connect('localhost', 'user', 'password') or die($connect_error);
    mysql_select_db('email_logs') or die($connect_error);

    $sql = "INSERT INTO client_data (name, email) VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['email']) . "')";
    mysql_query($sql);
    mysql_close();
    header("Location: thankyou.php");
    exit();
}
?>

Upvotes: 0

Views: 2590

Answers (4)

IRSHAD
IRSHAD

Reputation: 2933

Try with the below piece of code

fileName:fix.php

<?php
ob_start();
...
header('Location: page1.php');
...
ob_end_flush();
?>

Upvotes: 0

Avinash Singh
Avinash Singh

Reputation: 11

This may help you.

ob_start();

You can add this at the top of thankyou.php

Upvotes: 1

Jeff
Jeff

Reputation: 1017

Try this at the top of the script

ob_start("ob_gzhandler");

Upvotes: 0

RbG
RbG

Reputation: 3193

your code is fine...if u want u can try defining relative paths like.../path/to/thankyou.php..watch what happens..if it still not running..then check by error_reporting(E_ALL);ini_set('display_errors', 1); and tell us what the actual error

Upvotes: 1

Related Questions