私は構築しているページのポートフォリオWebサイトを1つ持っており、PHPスクリプトを使用して処理する必要がある連絡フォームがあります。私はそれがPHPになると私は初心者ですので、これを動作させるのに問題があります。私はいくつかの検索を行ったが、私が探しているものを見つけることができない。HTML用のPHPメール送信スクリプトが必要フォーム
これは私が作成したPHPコンタクトページからコピーしましたが、PHPとフォームは同じページにあり、フォームを処理するには外部send.phpが必要です。
<?php
$error = ''; // error message
$name = ''; // sender's name
$email = ''; // sender's email address
$company = ''; // company name
$subject = ''; // subject
$comment = ''; // the message itself
if(isset($_POST['send']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$subject = $_POST['subject'];
$comment = $_POST['comment'];
if($error == '')
{
if(get_magic_quotes_gpc())
{
$message = stripslashes($message);
}
// the email will be sent here
// make sure to change this to be your e-mail
$to = "[email protected]";
// the email subject
// '[Contact Form] :' will appear automatically in the subject.
// You can change it as you want
$subject = '[Contact Form] : ' . $subject;
// the mail message (add any additional information if you want)
$msg = "From : $name \r\ne-Mail : $email \r\nCompany : $company \r\nSubject : $subject \r\n\n" . "Message : \r\n$message";
mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");
}
}
if(!isset($_POST['send']) || $error != '')
{
header("location: http://www.#.com/#contact");
}
?>
は、だから私は持っていたい私のフォームのために:
<form method="post" action="send.php" class="form">
私は、フォームを検証するためにHTML5とjQueryを使用する予定なので、私は実際にのみ情報をキャプチャし、電子メールを送信するスクリプトが必要単一の住所に送信後、スクリプトをContactページにリダイレクトします。
編集:
私はGoogleでしばらく過ごした後、解決策を見つけました。 http://www.website.com/#contact ");?一つには >
この質問をする前に、明らかにこれに関する他の何百もの質問を見ていないのです。 –