Generate shopify queries and store them in MySQL from another hosting

0

I have an online store in shopify , I would like to use the following code php to insert data in a database in another hosting.

Specifically, I want to save emails from visitors who sign up for a form.

<?php
    $conexion = mysqli_connect("host", "user", "password", "database");

    $email = $_POST['email'];

    $sql = "INSERT into suscriptores (suscriptor) VALUES('$email')";
    $consulta = mysqli_query($conexion, $sql);
?>

I would like to know if it is possible that the emails that are registered in the form that I have on the website in shopify can reach a database hosted on another hosting.

I have insecurity due to the type of platform that is shopify that does not allow me to send the data that I want to save to that external database. Thanks:)

    
asked by Jesus 29.12.2016 в 16:56
source

2 answers

0

To make a connection to a remote server, you could do something like this:

$db_host        = 'PON.TU.DIRECCION.IP';
$db_user        = 'user';
$db_pass        = 'password';
$db_database    = 'database'; 
$db_port        = '3306';

$conexion = mysqli_connect($db_host,$db_user,$db_pass,$db_database,$db_port);
    
answered by 29.12.2016 / 17:02
source
0

Shopify is a platform offered in the "as a service" mode, that is, the management of the software that runs there is done by shopify people (unless you have Shopify Plus), the owner of the store you can only make some adjustments to the visual part of it (I imagine you already knew that), in your case if what you have is a form in the store and you are capturing data from customers (or potential customers) by there, these data will be registered directly in the shopify system (of your store), to be able to take that information to another system (a second system) you have to work with the shopify API of shopify or with the notification system based on webhooks, like Do you capture the data? You can follow one of the following two strategies:

  • Define a webhook in your store (here it says as: link ) that is activated when a new user registers in the store, which should be when the form you mentioned receives a new customer.

  • Program everything on your alternate server (the one that will run the php script) so that it invokes the endpoint of "customers" of your store in shopify (Here the available methods are described: link ) so that a php script through a task scheduled on the server (alternate, not in shopify) verifies each X time by new users registered in the store and register them in your DB mysql.

  • I hope it's useful.

        
    answered by 23.09.2017 в 01:38