I want to have an email sending system on my site.
The problem is when I try to assign a variable text from my HTML file it does not happen. I want that what is inside the variable should be written in the message of the email. Here's my code:
<html>
<?php include('form.php'); ?>
<head>
</head>
<body>
<form action="./form.php" method="post">
<div name="name"><input type="text" id="name"></div>
<div name="surname"><input type="text" id="surname"></div>
<div name="message"><textarea rows="4" cols="50" id="message">Inserisci qui il tuo testo.</textarea></div>
<div name="subject"><select id="subject">
<option selected="selected">--Inserisci Oggetto--</option>
<option>Registrazione al sito</option>
<option>Recupero credenziali</option>
</select></div>
<input type="submit" value="Invia penzolini"/>
<input type="hidden" name="button_pressed" value="1" />
</form>
</body>
</html>
<?php
$dochtml = new domDocument();
$dochtml->loadHTML('index.html');
if(isset($_POST['button_pressed']))
{
//prendi nome
$name = $dochtml->getElementById('name');
//prendi cognome
$surname = $dochtml->getElementById('surname');
//prendi l'oggetto della mail
$subject = $dochtml->getElementById('subject');
//msg<70 caratteri
$msg = "Inviato da" . ' ' . $name . $surname . ' ' . $dochtml->getElementById('message'); // /n=spazio
// manda mail
mail("panzersit@gmail.com",$subject,$msg);
echo 'Email inviata.';
}
?>