0

作業中の Web サイトに PHP フォームを追加しようとしています。PHP には詳しくありませんが、ファイルをuploadCMS のフォルダーに入れました。

jQueryと他のファイルを正しくリンクしたと思います.PHPファイルを編集してメールなどを入れました.これは別のPHP検証ファイルも呼び出します.

とにかく、正常に表示され、入力できますが、404ページに移動して機能しません。

私の質問は、php ファイルにリンクするためにどのリンク規則を使用すればよいですか? また、それは正しい場所にあるのでしょうか? CMSがインストールされているcPanelを使用しています。

置く代わりに: を入れるaction="url([[root_url]]/uploads/scripts/form-to-email.php" べきaction="uploads/scripts/form-to-email.php"ですか?

問題のページはこちら: www.edelweiss-web-design.com.au/captainkilowatt/

また、統合できる優れたキャプチャを知っている人はいますか...? ありがとう!

<div class="contact-form">
    <h1>Contact Us</h1>
    <form id="contact-form" method="POST" action="uploads/scripts/form-to-email.php">

        <div class="control-group">
            <label>Your Name</label>
            <input class="fullname" type="text" name="fullname" />
        </div>

        <div class="control-group">
            <label>Email</label>
            <input class="email" type="text" name="email" />
        </div>

        <div class="control-group">
            <label>Phone (optional)</label>
            <input class="phone" type="text" name="phone" />
        </div>

        <div class="control-group">
            <label>Message</label>
            <textarea class="message" name="message"></textarea>
        </div>

        <div id="errors"></div>

        <div class="control-group no-margin">
            <input type="submit" name="submit" value="Submit" id="submit" />
        </div>

    </form>
    <div id='msg_submitting'><h2>Submitting ...</h2></div>
    <div id='msg_submitted'><h2>Thank you !<br> The form was submitted Successfully.</h2></div>
</div>

これがphpです:

<?php
/*
Configuration
You are to edit these configuration values. Not all of them need to be edited.
However, the first few obviously need to be edited.
EMAIL_RECIPIENTS - your email address where you want to get the form submission.

*/

$email_recipients = "contact@edelweiss-web-design.com.au";//<<=== enter your email address here
//$email_recipients = "mymanager@gmail.com,his.manager@yahoo.com"; <<=== more than one recipients like this


$visitors_email_field = 'email';//The name of the field where your user enters their email address
//This is handy when you want to reply to your users via email
//The script will set the reply-to header of the email to this email
//Leave blank if there is no email field in your form
$email_subject = "New Form submission";

$enable_auto_response = true;//Make this false if you donot want auto-response.

//Update the following auto-response to the user
$auto_response_subj = "Thanks for contacting us";
$auto_response ="
Hi

Thanks for contacting us. We will get back to you soon!

Regards
Captain Kilowatt
";

/*optional settings. better leave it as is for the first time*/
$email_from = ''; /*From address for the emails*/
$thank_you_url = 'http://www.edelweiss-web-design.com.au/captainkilowatt.html';/*URL to redirect to, after successful form submission*/

/*
This is the PHP back-end script that processes the form submission.
It first validates the input and then emails the form submission.
The variable $_POST contains the form submission data.
*/
if(!isset($_POST['submit']))
{
// note that our submit button's name is 'submit'
// We are checking whether submit button is pressed
// This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!".print_r($_POST,true);
exit;
}

require_once "http://edelweiss-web-design.com.au/captainkilowatt/upload/scripts/formvalidator.php";
//Setup Validations
$validator = new FormValidator();
$validator->addValidation("fullname","req","Please fill in Name");
$validator->addValidation("email","req","Please fill in Email");
//Now, validate the form
if(false == $validator->ValidateForm())
{
echo "<B>Validation Errors:</B>";

$error_hash = $validator->GetErrors();
foreach($error_hash as $inpname => $inp_err)
{
echo "<p>$inpname : $inp_err</p>\n";
}
exit;
}
$visitor_email='';
if(!empty($visitors_email_field))
{
$visitor_email = $_POST[$visitors_email_field];
}

if(empty($email_from))
{
$host = $_SERVER['SERVER_NAME'];
$email_from ="forms@$host";
}

$fieldtable = '';
foreach ($_POST as $field => $value)
{
if($field == 'submit')
{
continue;
}
if(is_array($value))
{
$value = implode(", ", $value);
}
$fieldtable .= "$field: $value\n";
}

$extra_info = "User's IP Address: ".$_SERVER['REMOTE_ADDR']."\n";

$email_body = "You have received a new form submission. Details below:\n$fieldtable\n $extra_info";

$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
@mail(/*to*/$email_recipients, $email_subject, $email_body,$headers);

//Now send an auto-response to the user who submitted the form
if($enable_auto_response == true && !empty($visitor_email))
{
$headers = "From: $email_from \r\n";
@mail(/*to*/$visitor_email, $auto_response_subj, $auto_response,$headers);
}

//done.
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest')
{
//This is an ajax form. So we return success as a signal of succesful processing
echo "success";
}
else
{
//This is not an ajax form. we redirect the user to a Thank you page
header('Location: '.$thank_you_url);
}
?><?php
/*
Configuration
You are to edit these configuration values. Not all of them need to be edited.
However, the first few obviously need to be edited.
EMAIL_RECIPIENTS - your email address where you want to get the form submission.

*/

$email_recipients = "contact@edelweiss-web-design.com.au";//<<=== enter your email address here
//$email_recipients = "mymanager@gmail.com,his.manager@yahoo.com"; <<=== more than one recipients like this


$visitors_email_field = 'email';//The name of the field where your user enters their email address
//This is handy when you want to reply to your users via email
//The script will set the reply-to header of the email to this email
//Leave blank if there is no email field in your form
$email_subject = "New Form submission";

$enable_auto_response = true;//Make this false if you donot want auto-response.

//Update the following auto-response to the user
$auto_response_subj = "Thanks for contacting us";
$auto_response ="
Hi

Thanks for contacting us. We will get back to you soon!

Regards
Captain Kilowatt
";

/*optional settings. better leave it as is for the first time*/
$email_from = ''; /*From address for the emails*/
$thank_you_url = 'http://www.edelweiss-web-design.com.au/captainkilowatt.html';/*URL to redirect to, after successful form submission*/

/*
This is the PHP back-end script that processes the form submission.
It first validates the input and then emails the form submission.
The variable $_POST contains the form submission data.
*/
if(!isset($_POST['submit']))
{
// note that our submit button's name is 'submit'
// We are checking whether submit button is pressed
// This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!".print_r($_POST,true);
exit;
}

require_once "http://www.edelweiss-web-design.com.au/captainkilowatt/upload/scripts/formvalidator.php";
//Setup Validations
$validator = new FormValidator();
$validator->addValidation("fullname","req","Please fill in Name");
$validator->addValidation("email","req","Please fill in Email");
//Now, validate the form
if(false == $validator->ValidateForm())
{
echo "<B>Validation Errors:</B>";

$error_hash = $validator->GetErrors();
foreach($error_hash as $inpname => $inp_err)
{
echo "<p>$inpname : $inp_err</p>\n";
}
exit;
}
$visitor_email='';
if(!empty($visitors_email_field))
{
$visitor_email = $_POST[$visitors_email_field];
}

if(empty($email_from))
{
$host = $_SERVER['SERVER_NAME'];
$email_from ="forms@$host";
}

$fieldtable = '';
foreach ($_POST as $field => $value)
{
if($field == 'submit')
{
continue;
}
if(is_array($value))
{
$value = implode(", ", $value);
}
$fieldtable .= "$field: $value\n";
}

$extra_info = "User's IP Address: ".$_SERVER['REMOTE_ADDR']."\n";

$email_body = "You have received a new form submission. Details below:\n$fieldtable\n $extra_info";

$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
@mail(/*to*/$email_recipients, $email_subject, $email_body,$headers);

//Now send an auto-response to the user who submitted the form
if($enable_auto_response == true && !empty($visitor_email))
{
$headers = "From: $email_from \r\n";
@mail(/*to*/$visitor_email, $auto_response_subj, $auto_response,$headers);
}

//done.
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest')
{
//This is an ajax form. So we return success as a signal of succesful processing
echo "success";
}
else
{
//This is not an ajax form. we redirect the user to a Thank you page
header('Location: '.$thank_you_url);
}
?>

phpファイルを追加しました。そのため、アクション部分でフォームを送信すると、404 が表示されなくなり、「form-to-email.php」ページのある空白のページに移動します。ただし、私が知る限り、スクリプトは機能していません。繰り返しますが、私は html と css を知っていますが、javascript はほとんど知りませんが、php はどのように機能するのでしょうか...?

私は何を間違っていますか?

4

2 に答える 2

2

PHP でゼロからフォームを構築しようとする代わりに、CMS 用のモジュールの 1 つを使用することをお勧めします。CMS 組み込み関数を使用する方がはるかに安全であり、それが最初に CMS を使用するポイントです。CMS made simple の場合、formbuilder モジュールは次の場所にあります: http://dev.cmsmadesimple.org/projects/formbuilder

于 2016-05-27T22:26:56.973 に答える
0

すべてのコメントをありがとう。

キャプチャ (PHP) を含む別のフォームを見つけ、それをそのまま CMSMS アップロード フォルダーにアップロードすることで構造全体を保存しました。次に、iframe を使用してページにフォームを埋め込み、CSS と文言でいくつかの細部を変更しました。ボブはあなたの叔父さんです。問題なく動作します。

興味のある人のために、私は使用しました: www.html-form-guide.com/contact-form/creating-a-contact-form.html

これは無料であり、私はこのサイトまたはそれに関連するサイトとは一切関係がないため、スパムを送信しようとしているわけではありません.

于 2016-05-30T00:19:36.237 に答える