1

I have one log in page, in which user has to enter his email id, which he has used during sign up. After clicking on submit, it redirects to verify.php If email id is correct,(for storing sign up information, DB is used.) verify.php redirects to download.php page. Sign in is working fine on localhost.(Xampp) But after making it live, submit redirects to verify.php, but shows blank page. After applying error reporting, following errors are coming. Find below attachment for error and verify.php file.

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

$db = new mysqli("localhost", "root", "", "testembark");

$email = $_POST['email'];
$email = stripslashes($email);
$sql = "SELECT * FROM signup WHERE email='$email'";
$result = mysqli_query($db,$sql) or die(mysqli_error($db));

$row_cnt = mysqli_num_rows($result);

if($row_cnt==1){

    session_start();

    $_SESSION['email']= $email;


    header("location:download-product.php");
else {
    echo "Wrong Email";
}

?>

Errors

IROEGBU
  • 948
  • 16
  • 33

4 Answers4

2

Your database connection failed. You should always check if connection was successful before proceeding to use the connection.

$db = new mysqli("localhost", "root", "", "testembark");
if ($db->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}

This way the script dies before you attempt to use a nonexistent connection.
Also, you are missing a } before your else block.
You should migrate your database as well, moving just the project dir won't do. Find instructions to move your database here
Note that: your connection details will change to what you have on your server e.g. $db = new mysqli("domain", "username", "password", "database");

Community
  • 1
  • 1
IROEGBU
  • 948
  • 16
  • 33
  • Ok. That means I have to create same database on for live server usingphpmyadmin as created on local host, using CPanel details of regarding website? – Rucha Karmarkar Aug 21 '14 at 12:14
  • @RuchaKarmarkar yes, that is very correct. Then you have update your connection details `$db = new mysqli("localhost", "root", "", "testembark");` to match the server details. – IROEGBU Aug 21 '14 at 12:21
1

In localhost(Xampp) no need to provide password for database,But in live you have password to your database.

So mention your password here $db = new mysqli("localhost", "root", "your db password", "testembark");

DRK
  • 160
  • 1
  • 4
  • 14
  • Ok. That means I have to create same database on for live server usingphpmyadmin as created on local host, using CPanel details of regarding website? – Rucha Karmarkar Aug 21 '14 at 12:16
  • Yes, you have to create database in your server and use those details. – DRK Aug 21 '14 at 12:25
0

Database logons seems to be wrong, and you forgot a '}' char, there:

if($row_cnt==1){
    session_start();

    $_SESSION['email']= $email;

    header("location:download-product.php");

// THERE
}else{
    echo "Wrong Email";
}
Remy San
  • 525
  • 1
  • 4
  • 24
0
$db = new mysqli("localhost", "root", "", "testembark");

I think the problem is here.

As I understand, everything works fine on your local machine, but on the real server it fails. You need to check if username and password are right for the database, installed on the real server.

dmppka
  • 36
  • 4