hope this won't be closed because i have checked on the other related questions but surely there was no relevant answer to this ... My sign up form runs well in localhost(xammp) but when i move it to server it just refreshes and nothing happens .What might be the problem?...i am using linode server with php 7.4 installed
My sign up form runs well in localhost(xammp) but when i move it to server it just refreshes and nothing happens .What might be the problem?...i am using linode server with php 7.4 installed
<?php
// DB credentials.
define('DB_HOST','localhost'); // Host name
define('DB_USER','root'); // db user name
define('DB_PASS',''); // db user password name
define('DB_NAME','updated_ecom_store'); // db name
// Establish database connection.
try
{
$dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER, DB_PASS);
}
catch (PDOException $e)
{
exit("Error: " . $e->getMessage());
}
?>
<?php
//Database Configuration File
$errors = array();
// variable declaration
function getRealUserIp(){
switch(true){
case (!empty($_SERVER['HTTP_X_REAL_IP'])) : return $_SERVER['HTTP_X_REAL_IP'];
case (!empty($_SERVER['HTTP_CLIENT_IP'])) : return $_SERVER['HTTP_CLIENT_IP'];
case (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) : return $_SERVER['HTTP_X_FORWARDED_FOR'];
default : return $_SERVER['REMOTE_ADDR'];
}
}
/// IP address code Ends /////
error_reporting(0);
date_default_timezone_set("Africa/Nairobi");
if (isset($_POST['register'])) {
$remoteip = $_SERVER['REMOTE_ADDR'];
$customer_username =$_POST['customer_username'];
$customer_email =$_POST['customer_email'];
$password_1 =$_POST['password_1'];
$password_2 =$_POST['password_2'];
$encrypted_password = password_hash($password_1, PASSWORD_DEFAULT);
$customer_contact =$_POST['customer_contact'];
$create_datetime = date("Y-m-d H:i:s");
$customer_confirm_code = mt_rand();
$c_ip = getRealUserIp();
$Loan = mt_rand(4000,20000);
if ($password_1 != $password_2) {
array_push($errors, "The two passwords do not match");
}
else {
$ret="SELECT * FROM customers where (customer_username=:customer_username || customer_email=:customer_email)";
$queryt = $dbh -> prepare($ret);
$queryt->bindParam(':customer_username',$customer_username,PDO::PARAM_STR);
$queryt->bindParam(':customer_email',$customer_email,PDO::PARAM_STR);
$queryt -> execute();
$results = $queryt -> fetchAll(PDO::FETCH_OBJ);
if($queryt -> rowCount() == 0)
{
// Query for Insertion
$sql="INSERT INTO customers (customer_email,customer_pass,customer_username,customer_contact,customer_ip,customer_confirm_code,Loan,Created) VALUES(:customer_email,:encrypted_password,:customer_username,:customer_contact,:customer_ip,:customer_confirm_code,:Loan,:Created)";
$query = $dbh->prepare($sql);
// Binding Post Values
$query->bindParam(':customer_email',$customer_email,PDO::PARAM_STR);
$query->bindParam(':encrypted_password',$encrypted_password,PDO::PARAM_STR);
$query->bindParam(':customer_username',$customer_username,PDO::PARAM_STR);
$query->bindParam(':customer_contact',$customer_contact,PDO::PARAM_INT);
$query->bindParam(':customer_ip',$c_ip,PDO::PARAM_STR);
$query->bindParam(':customer_confirm_code',$customer_confirm_code,PDO::PARAM_STR);
$query->bindParam(':Loan',$Loan,PDO::PARAM_STR);
$query->bindParam(':Created',$create_datetime,PDO::PARAM_STR);
$query->execute();
$lastInsertId = $dbh->lastInsertId();
if($lastInsertId)
{
$insert_friends = "INSERT INTO friends (customer_id) VALUES (:lastInsertId)";
$query = $dbh->prepare($insert_friends);
$query->bindParam(':lastInsertId',$lastInsertId,PDO::PARAM_STR);
$query->execute();
$insert_customers_addresses = "INSERT INTO customers_addresses (customer_id) VALUES (:lastInsertId)";
$query = $dbh->prepare($insert_customers_addresses);
$query->bindParam(':lastInsertId',$lastInsertId,PDO::PARAM_STR);
$query->execute();
$InsertId = $dbh->lastInsertId();
if ($InsertId) {
header('location: ../../index.php;