首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >单击Sumbit将我带到php页面

单击Sumbit将我带到php页面
EN

Stack Overflow用户
提问于 2013-10-01 10:36:43
回答 1查看 183关注 0票数 0

我已经学习了本教程的第一部分:http://www.1stwebdesigner.com/tutorials/custom-php-contact-forms/,并根据我的需要进行了编辑,但当我在表单上单击Submit时,它会将我带到php页面。

当我单击提交时,我希望它提交表单,表单的结果将通过电子邮件发送给我。我不懂PHP (所以我在看教程),所以这可能是一个非常愚蠢的错误:/

我的HTML:

代码语言:javascript
运行
复制
<form action="mail.php" method="POST">

            <fieldset>

                <h3>Apply</h3>
                    <div class="alert alert-info">
                        <p><strong>Recruitment Status:</strong> Open!</p>
                    </div>
                <hr>
                    <div>
                    <label>Minecraft Username</label>
                    <input type="text" placeholder="Very important!" name="username">
                    <label>Which are you best at?</label>
                    <select name="BestAt">
                        <option>Mining</option>
                        <option>Hunting</option>
                        <option>Farming</option>
                        <option>PvP</option>
                        <option>Raiding</option>
                        <option>Building</option>
                        <option>Redstone</option>
                        <option>Other</option>
                    </select>
                    <label>How many hours are you online each day?</label>
                    <select name="TimeOnline">
                        <option>Less than 2 hrs</option>
                        <option>2-4 hrs</option>
                        <option>4-6 hrs</option>
                        <option>6-8 hrs</option>
                        <option>8-10 hrs</option>
                        <option>More than 10 hrs</option>
                    </select>
                    <label>What rank are you?</label>
                    <select name="rank">
                        <option>Default</option>
                        <option>Member</option>
                        <option>Tier 1</option>
                        <option>Tier 2</option>
                        <option>Tier 3</option>
                        <option>Tier 4</option>
                        <option>Tier 5</option>
                        <option>Moderator</option>
                        <option>Admin/Owner</option>
                    </select>
                    <label>What country do you live in?</label>
                    <input type="text" placeholder="Which Country?" name="country">
                    <label>How old are you?</label>
                    <input type="text" placeholder="Optional" name="age">
                    <label>Previous factions and why you left?</label>
                    <textarea rows="10" placeholder="One faction per line" name="PreviousFactions"></textarea>
                    <label>Why do you want to join Kando?</label>
                    <textarea rows="4" placeholder="Should be atleast 2 sentences" name="WhyYouWantToJoin"></textarea>
                    <hr>
                    <p>You may provide us with your forum username rather than email address or vice versa. It is required that you enter atleast one of them.</p>
                    <label>Email Address (So we can tell you if you've been accepted)</label>
                    <input type="email" placeholder="Please fill in" name="email">
                    <label>Forum Username (So we can add you to our private forum)</label>
                    <input type="text" placeholder="one of these" name="ForumUsername">
                    <hr>
                    <label class="checkbox">
                    <input type="checkbox" value="" name="AgreeToRules">Do you agree to follow our rules?</label>   
                    <hr>
                    <button class="btn btn-large btn-block btn-primary" type="submit" name="submit" value="Send">Submit Application</button>
                    </div>
            </fieldset>

        </form>

我的PHP:

代码语言:javascript
运行
复制
<?php $username = $_POST['username'];
$BestAt = $_POST['BestAt'];
$TimeOnline = $_POST['TimeOnline'];
$rank = $_POST['rank'];
$country = $_POST['country'];
$age = $_POST['age'];
$PreviousFactions = $_POST['PreviousFactions'];
$WhyYouWantToJoin = $_POST['WhyYouWantToJoin'];
$email = $_POST['email'];
$ForumUsername = $_POST['ForumUsername'];
$formcontent=" From: $username \n Best At: $BestAt \n Time Online Daily: $TimeOnline \n Rank: $rank \n Country: $country \n Age: $age \n Previous Factions: $PreviousFactions \n Why $username wants to join: $WhyYouWantToJoin \n Email: $email \n Forum Username: $ForumUsername";
$recipient = "email@address.com";
$subject = "Kando Application!";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>

任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2013-10-01 14:28:47

在这种情况下,您需要使用google API key在有人提交表单时通过您的页面发送电子邮件。试着在你的页面上使用下面的php:

代码语言:javascript
运行
复制
    <?php
define('EMAIL_FOR_REPORTS', 'Your Email address here');
define('RECAPTCHA_PRIVATE_KEY', 'Your website private key');
define('FINISH_URI', 'Your web page after submit a form');
define('FINISH_ACTION', 'redirect');
define('FINISH_MESSAGE', 'Your message to show for confirmation');
require_once('Your handler php file here');
?>

正如你在上面的例子中看到的,你只需要添加handler.php就可以在你的表单页面上使用它。

如果你有问题,只要给我一个你的测试文件的链接,我会指导你如何使用它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19107059

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档