Good morning everyone
I have a situation with a website in Prontus , what happens is that there is a section to subscribe to the Newsletter, but the code apparently does not work, to make the verification that it sent information to the database, what you want to do is that the content of the form also send it to an email. Why should I check like this and not look directly at the database? Because I do not have access to the database.
Website: www.conchali.cl
Code:
HTML CODE
<div id="form-main">
<div id="form-div">
<form class="form" id="form1" method="post" action="guardar.php">
<div class="head">
<img class="env" src="/site/imag/global/envelope.png" width="90px" alt="">
</div>
<h2 class="tit">Suscríbete a nuestro boletín<br> informativo aquí</h2>
<p class="par">Recibirás todos los panoramas y actividades de Conchalí.</p>
<p class="name">
<input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="Ingresa tu nombre" id="name" />
</p>
<p class="email">
<input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Ingresa tu email" />
</p>
<div class="submit">
<input type="submit" name="submit" value="ENVIAR" id="button-blue"/>
<div class="ease"></div>
</div>
</form>
</div>
</div>
PHP CODE
<?php
$db_host='localhost';
$db_user='name';
$db_email='email';
$db_name='mailing';
$$db_table_name='suscriptores';
$db_connection = mysql_connect($db_host,$db_user,$db_email);
if (!$db_connection) {
die('Gracias!, pronto recibirás información de nuestras actividades');
}
$subs_name = utf8_decode($_POST['name']);
$subs_email = utf8_decode($_POST['email']);
$resultado=mysql_query("SELECT * FROM ".$db_table_name." WHERE Email = '".$subs_email."'", $db_connection);
if (mysql_num_rows($resultado)>0)
{
header('Location: Fail.html');
}else{
$insert_value = 'INSERT INTO '' . $db_name . ''.''.$db_table_name.'' ('Name','Email') VALUES ("' . $subs_name . '", "' . $subs_last . '", "' . $subs_email . '")';
mysql_select_db($db_name, $db_connection);
$retry_value = mysql_query($insert_value, $db_connection);
if (!$retry_value) {
die('Error: ' . mysql_error());
}
header('Location: Success.html');
}
mysql_close($db_connection);
?>
That is the code that was originally on the page, and the one that wants to verify if it is sending information correctly.
I replaced it with this code so that it does not save in the database but directly send it to the email.
Code
<?php
$subs_name = utf8_decode($_POST['name']); //**Recoge datos del campo Nombre
$subs_email = utf8_decode($_POST['email']); //**Recoge datos del campo email
$mail = "Nombre: " . $subs_name . "\n" . "Correo: " . $subs_email . "\n" . "Enviado desde pagina de conchali";
//Titulo
$titulo = "Suscribción nueva - Conchali";
//cabecera
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
//dirección del remitente
$headers .= "From: Web Conchali < [email protected] >\r\n";
//Enviamos el mensaje a tu_dirección_email
$bool = mail("[email protected]",$titulo,$mail,$headers);
if($bool){
echo "Mensaje enviado";
}else{
echo "Mensaje no enviado";
}
?>
But do not send any information, could you help me? And in what way can the two PHP codes be joined? To save in the database and also send to the email.
Thank you very much.