0

index.html と contacto.php があります。

contacto.php は、おそらくユーザーの情報を複数の受信者に送信するためのものですが、送信していません。

これは私の index.html です (javascript は無視してください)

<form action="contacto.php" method="POST">

        <fieldset style="margin: 0px 0 0 0"; >
<br/><br/>  <br/><br/>  <br/><br/>  <br/><br/>


<input maxlength="255" name="Form testing" size="20" type="hidden" value="Form-name-here" /><br>    

 <input value="Nome" onfocus="if (this.value == 'Nome') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Nome';}" maxlength="255" name="name" size="20" type="text" /><br>

<input value="Telemóvel" onfocus="if (this.value == 'Telemóvel') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Telemóvel';}" id="phone" maxlength="40" name="phone" size="20" type="text" /><br>

<input onfocus="if (this.value == 'Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email';}" value="Email" id="email" maxlength="80" name="email" size="20" type="text" /><br>

<input onfocus="if (this.value == 'Localidade') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Localidade';}" value="Localidade" maxlength="255" name="location" size="20" type="text" /><br>

.

そして、これは私の contacto.php です:

<?php
 // Get Data
 $name = strip_tags($_POST['name']);
 $email = strip_tags($_POST['email']);
 $phone = strip_tags($_POST['phone']);
 $location = strip_tags($_POST['location']);

 $headers .="De: Form thingy <examplealpha@someemail.com>";
 $headers .="CC: Mail1 <example1@someemail.com>";
 $headers .=", Mail2 <example2@someemail.com>";

 header("Location: thankyou.html");  //Redirect to Thank You HTML page after email is sent


 // Send message
 mail( "example1@someemail.com", "Formulário Facebook Av. Grátis",
 "Name: $name\nEmail: $email\nPhone: $phone\nLocation: $location\n",
  $headers );
 ?>
4

2 に答える 2

1

ヘッダーの場所を送信前ではなく送信後にリダイレクトする

// Send message
mail( "example1@someemail.com", "Formulário Facebook Av. Grátis",
 "Name: $name\nEmail: $email\nPhone: $phone\nLocation: $location\n",
 $headers );

 header("Location: thankyou.html");  //Redirect to Thank You HTML page after email is sent
于 2013-03-22T21:11:27.200 に答える
1

変化する:

$headers .="De: Form thingy <examplealpha@someemail.com>";

に:

$headers ="From: Form thingy <examplealpha@someemail.com>";

"De: は、PHP マニュアルに従って標準ではありません。"From:... を使用してください。

http://php.net/manual/en/function.mail.php

http://php.net/manual/fr/function.mail.php

完全なコード:

<?php
// Get Data
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$phone = strip_tags($_POST['phone']);
$location = strip_tags($_POST['location']);

$headers ="From: Form thingy <examplealpha@someemail.com>";
$headers .="CC: Mail1 <example1@someemail.com>";
$headers .=", Mail2 <example2@someemail.com>";

// Send message
mail( "example1@someemail.com", "Formulário Facebook Av. Grátis",
 "Name: $name\nEmail: $email\nPhone: $phone\nLocation: $location\n",
  $headers );

header("Location: thankyou.html");  //Redirect to Thank You HTML page after email is sent
?>
于 2013-03-22T22:18:54.030 に答える