What error is this net :: ERR_NAME_NOT_RESOLVED in php?

0

Hello, I am trying to pass parameters to a php file, email and password, for login use by following url: " link " and the following warning appears

  

net :: ERR_NAME_NOT_RESOLVED

Would the parameters be in trouble? Well, when I run the url in the hand "wheel" of course, it warns that the two variables are undefined

  

Notice: Undefined index: ema in /var/www/vigilantescomunitarios.com/public_html/www/php/login.php on line 17

     

Notice: Undefined index: sen in /var/www/vigilantescomunitarios.com/public_html/www/php/login.php on line 18

Controller:

var ema = usuario.email;
var sen = usuario.senha;
$http.post("http://www.vigilantescomunitarios.com/php/login.php?ema="+ema+"&sen="+sen).success(function (response){
        console.log(response);
}

PHP:

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

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type,x-prototype-version,x-  requested-with');

include_once("conPDO.php");

$pdo = conectar();

$email = $_GET['ema'];
$senha = $_GET['sen'];
echo $email.' - '.$senha;
?>
    
asked by anonymous 10.08.2016 / 14:24

1 answer

2

The problem is that the site does not have the www. subdomain. For this reason it is shown error of not finding the domain, because in fact it does not exist. Removing www. from URL will not exist. ;)

Solution:

Method 1 via Javascript:

$http.post("http://vigilantescomunitarios.com/php/login.php?ema="+ema+"&sen="+sen).success(function (response){
        console.log(response);
}
  

Simply remove www. .

But that does not solve the whole problem!

Method 2 via Apache:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  

This will redirect http://www... to http://...

Method 2 via Nginx:

server {
    server_name www.vigilantescomunitarios.com;
    return 301 $scheme://vigilantescomunitarios.com$request_uri;
}
  

This will redirect http://www... to http://... or https://www... to https://... .

To perform Method 2 you need to configure DNS, thus pointing the subdomain and domain to the same server.

For example:

Imageandsomeinformationhasbeenextracted of this DigitalOcean tutorial . The configuration panel will vary from DNS to DNS.

    
10.08.2016 / 14:48