
Necesito ayuda con el cambio de remitente de un formulario
Publicado por Diego Reyes (2 intervenciones) el 23/11/2016 04:32:40
Hola buenas noches, disculpen si me equivoco de hilo pero necesito ayuda con un codigo php de un formulario donde no consigo cambiarle el nombre del remitente, el codigo php es el siguiente
y mi formulario en html es asi
por favor si me pueden ayudar se los agradeceria enormemente
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mail->From = $_POST['email'];
$mail -> IsSMTP();
$mail -> SMTPAuth = true;
$to = 'xxx@xxx.com';
$host = 'smtp.xxx.com';
$port = '25';//"587";
$username = 'xxx@xxx.com';
$password = 'xxx';
$subject = 'Mensaje';
$human = $_POST['human'];
$mail->WordWrap = 50;
$mail->IsHTML(true);
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit'] && $human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo "<script>alert('Formulario Enviado');location.href ='javascript:history.back()';</script>";
} else {
echo "<script>alert('Error al enviar el formulario');location.href ='javascript:history.back()';</script>";
}
} else if ($_POST['submit'] && $human != '4') {
echo "<script>alert('Respondiste la pregunta antispam incorrectamente');location.href ='javascript:history.back()';</script>";
}
?>
y mi formulario en html es asi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<form method="post" action="bat/prueba.php">
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<label>*What is 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here">
<input id="submit" name="submit" type="submit" value="Submit">
</form>
por favor si me pueden ayudar se los agradeceria enormemente
Valora esta pregunta


0