機能するフォームを作成しようとしています。私は codeigniter を使用しています。ビューには次の形式があります。
<form class="renuncia_form" action="/formulario/send_form" method="post">
<p>
<label for="nombre">Nombre y apellidos:</label>
<input name="nombre" type="text" id="renuncia_nombre">
<br>
<label for="participe">Nº Partícipe: </label>
<input name="participe" type="text" id="renuncia_participe">
<br>
<label for="nombre_fondo">Nombre del Fondo de Inversión o SICAV: </label>
<input name="nombre_fondo" type="text" id="renuncia_fondo">
<br>
<label for="email">Direccion de correo electrónico: </label>
<input name="email" type="text" id="renuncia_email">
<br>
<input type="submit" value="Enviar" class="renuncia_submit" name="enviar">
</p>
</form>
そしてコントローラーにはこのphpがあります:
public function send_form(){
if($_POST['submit'] == "Submit")
{
$errorMessage = "";
if(empty($_POST['nombre']))
{
$errorMessage .= "<li>You forgot to enter your name</li>";
}
if(empty($_POST['participe']))
{
$errorMessage .= "<li></li>";
}
$varMovie = $_POST['nombre'];
$varName = $_POST['participe'];
if(empty($errorMessage))
{
$fs = fopen("mydata.csv","a");
fwrite($fs,$varName . ", " . $varMovie . "\n");
fclose($fs);
header("Location: thankyou.html");
exit;
}
}
}
フォームが正しいかどうかはわかりません。送信をクリックすると、「メールをありがとう」という新しいページに移動し、AJAXはありません。それだけです。
誰でもこれで私を助けることができますか?
編集:また、受信者の電子メールをどこに置くのですか?