PHP does not publish data in MySQL table

0

Hello!

I'm a beginner in PHP, I'm trying to build an HTML form that should use PHP code to send the data to a MySQL table.

It turns out that PHP code simply does nothing ... it does not publish data and does not return any error ...

Could anyone help me by pointing out what I might be doing wrong? I will be very grateful!

Below is the PHP code:

<?php
ini_set('default_charset','UTF-8');
$con=mysqli_connect("url","user","pass", "db_name");
mysqli_set_charset($con,"utf8");

if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

  $name = nl2br(htmlentities($_POST['nome'], ENT_QUOTES, 'UTF-8'));
  $rua = nl2br(htmlentities($_POST['rua'], ENT_QUOTES, 'UTF-8'));
  $numero = nl2br(htmlentities($_POST['numero'], ENT_QUOTES, 'UTF-8'));
  $bairro = nl2br(htmlentities($_POST['bairro'], ENT_QUOTES, 'UTF-8'));
  $cidade = nl2br(htmlentities($_POST['cidade'], ENT_QUOTES, 'UTF-8'));
  $telefone = nl2br(htmlentities($_POST['telefone'], ENT_QUOTES, 'UTF-8'));
  $nascimento = nl2br(htmlentities($_POST['nascimento'], ENT_QUOTES, 'UTF-8'));
  $email = nl2br(htmlentities($_POST['email'], ENT_QUOTES, 'UTF-8'));
  $deficiencia = nl2br(htmlentities($_POST['deficiencia'], ENT_QUOTES, 'UTF-8'));
  $deficienciasim = nl2br(htmlentities($_POST['deficienciasim'], ENT_QUOTES, 'UTF-8'));
  $escolaridade = nl2br(htmlentities($_POST['escolaridade'], ENT_QUOTES, 'UTF-8'));
  $formado = nl2br(htmlentities($_POST['formado'], ENT_QUOTES, 'UTF-8'));
  $sexo = nl2br(htmlentities($_POST['sexo'], ENT_QUOTES, 'UTF-8'));
  $estadocivil = nl2br(htmlentities($_POST['estadocivil'], ENT_QUOTES, 'UTF-8'));
  $filhos = nl2br(htmlentities($_POST['filhos'], ENT_QUOTES, 'UTF-8'));
  $habilitacao = nl2br(htmlentities($_POST['habilitacao'], ENT_QUOTES, 'UTF-8'));
  $possuiveiculo = nl2br(htmlentities($_POST['possuiveiculo'], ENT_QUOTES, 'UTF-8'));
  $situacaoatual = nl2br(htmlentities($_POST['situacaoatual'], ENT_QUOTES, 'UTF-8'));
  $pretensaosalarial = nl2br(htmlentities($_POST['pretensaosalarial'], ENT_QUOTES, 'UTF-8'));
  $regime = nl2br(htmlentities($_POST['regime'], ENT_QUOTES, 'UTF-8'));
  $podeviajar = nl2br(htmlentities($_POST['podeviajar'], ENT_QUOTES, 'UTF-8'));
  $conhecimentosespecificos = nl2br(htmlentities($_POST['conhecimentosespecificos'], ENT_QUOTES, 'UTF-8'));
  $falesobrevoce = nl2br(htmlentities($_POST['falesobrevoce'], ENT_QUOTES, 'UTF-8'));

  $conhecimentos = mysql_real_escape_string($conhecimentosespecificos);
  $falesobre = mysql_real_escape_string($falesobrevoce);

  $areadepreferencia = array();
  $area=implode(', ', $_POST['areadepreferencia']);

$result = mysqli_query($con,"INSERT INTO moderacurriculovesp (nome, rua, numero, bairro, cidade, telefone, nascimento, email, deficiencia, deficienciasim, escolaridade, formado, sexo, estadocivil, filhos, habilitacao, possuiveiculo, situacaoatual, areadepreferencia, pretensaosalarial, regime, podeviajar, conhecimentosespecificos, falesobrevoce) VALUES ('$name', '$rua', '$numero', '$bairro', '$cidade', '$telefone', '$nascimento', '$email', '$deficiencia', '$deficienciasim', '$escolaridade', '$formado', '$sexo', '$estadocivil', '$filhos', '$habilitacao', '$possuiveiculo', '$situacaoatual', '$area', '$pretensaosalarial', '$regime', '$podeviajar', '$conhecimentos', '$falesobre')");

// ENVIA EMAIL
$to      = '[email protected]';
$subject = 'Assunto do email';
$message = 'Corpo do email';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

//

header('Location: mensagem_enviada.html');

?>

Thank you!

    
asked by anonymous 09.05.2017 / 22:24

1 answer

0

It worked!

The problem was as follows in the lines:

$conhecimentos = mysql_real_escape_string($conhecimentosespecificos);
$falesobre = mysql_real_escape_string($falesobrevoce);

I used "mysql" instead of "mysql i " ...

Enabling errors as indicated by @rray was able to find out!

Many thanks to all who helped!

    
09.05.2017 / 22:38