Phpmail does not receive content within variable

Asked

Viewed 21 times

0

I have a form that should send an email, I created a file called email php. to create this function.

?php

$nome = $_REQUEST['name'];
$fone = $_REQUEST['phone'];
$email = $_REQUEST['email'];
$para = "[email protected]";
$assunto = "Contato pelo site";
$url = $_SERVER['HTTP_REFERER'];

	if ($url == "MEULINK/administracao.html") {
		$curso = "Administração";
	} elseif ($url == "MEULINK/ciencias-contabeis.html") {
		$curso = "Ciências Contábeis";
	} elseif ($url == "MEU LINK/landing-page/neurociencia.html") {
		$curso = "Neurociência";
	}

	$corpo = "<html><b>Contato pelo site</b><br><br>
	<b>Curso: </b> $curso<br>
	<b>Nome: </b> $nome<br>
	<b>Telefone: </b> $fone</br>
	<b>Email: </b> $email </html>"
	;

	$header = "Content-Type: text/html; charset= utf-8";
	$header .= "From: $email Reply-to: $email";

mail($para, $assunto, $corpo, $header);

header("location:$url?msg=enviado")
?>

In the case, the $course works only for the first condition. If the link is /science-contabeis.html it does not receive what is within $course

  • My advice is that you do not use string comparisons because the old false/positive is possible. Include in html an Hidden field and create a logic to pass it in your form containing a course id. so I think it will be better to manage. Another tip is you put a var_dump before ifs to scan what is coming

  • @Israelzebulon has any tips how to do? I did not understand the false or positive.

  • False positive comparisons with string can say that it does not exist because some character has been misinterpreted. For now do a vardump before the isfs and test the three cases see what’s coming in the variable.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.