Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
activate php form with javascript not working

This is the code. Man I'm sending this to my online server e-mail and the php form server is not working! The email never arrive! Anyone knows why it not working correctly?

`

Enter some text in the fields below, then press the "Submit form" button to submit the form.

name:
tel:
mail:
function myFunction() { document.getElementById("myForm").submit(); }
<?php

if (isset($_POST['submit'])){

$name     = $_POST['name'];
$tel      = $_POST['tel'];
$mailFrom = $_POST['mail'];


$subject  = "Solicitação de cotação recebida por ".$name;
$message  = "hello ".$tel;

$headers  = "Email: " .$mailFrom;
$txt      = "Você recebeu uma solicitação de cotação recebida por ".$name.".\n\n".$message;

$mailTo1   = 'marketing@macbrs.com.br';

mail($mailTo1,  $subject, $txt, $headers);

header("Location: action_page.php?mailsend");

}
?>

`

I want a code that makes connection with php and javascript to natural server and gmail! looks like this -

name title

button onclick calltoaction

function calltoaction

activate php

php post data

name title

send to mail!

if anyone can help!

Simple solutions man! Plz!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Beware there is certainly no $_POST['submit'] value, so the first test fails and nothing is done.

If you test the following in a test.php file :

<?php print_r($_POST); ?>
<form action="test.php" method="post">
 <p>Your name : <input type="text" name="name" /></p>
 <p>Your age : <input type="text" name="age" /></p>
 <p><input type="submit" value="OK"></p>
</form>

First call gives :

enter image description here

And when I fill and submit my form :

enter image description here

So, nothing about submit is received by the server.


EDIT


One more point : you can't assume that all the values are set, so your test could look like :

if (isset($_POST['name']) && isset($_POST['tel']) && isset($_POST['mail'])){
  // do what you need
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

As Philippe said, there is no $_POST['submit'].

Simply set the if as so:

if ($_POST) {

This checks if the $_POST has any value, so it comes in handy.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda