提交按钮,我的联系形式不提交和重定向 [英] Submit button for my contact form is not submitting and redirecting

查看:194
本文介绍了提交按钮,我的联系形式不提交和重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作我的第二个网站和整个创造这一个,我第一次在这里的计算器人都被一个惊人的帮助。
我可以浏览并找到几乎任何东西我wan't知道。
问题99%我有,我固定的我已经在这里阅读答案。
因此,首先感谢大家这么多!

这是我第一次张贴的东西,因为我无法找到我的code中的具体的答案。
有些人一个在这里有同样的问题,但是当我看他们的code,我只是失去了。
我知道,现在HTML中的公平位。这是我很无能的PHP。
我不是在寻找的东西看中了,我只是想创建一个简单的联系表格。

因此​​,这里是我的问题,code,我希望你们中的一些能够帮助我。

我使用的PHP code从YouTube的教程,它的deadeasy(如之前所说:第一次PHP)但我不能让它工作。虽然我做的一切一样的人在剪辑。他表示他的工作,所以我以我的方式非常好奇是不是?

我的状态不会发送,并点击提交按钮,我没有得到'谢谢'行之后。

下面是HTML:

 <形式方法=邮报行动=联系形式NAME =联系形式ID =联系形式>            <&OL GT;
                <立GT;
                    <标签=voornaam> Voornaam< /标签>
                    <输入类型=文本名称=voornaam/>
                < /李>
                <立GT;
                    <标签=achternaam> Achternaam< /标签>
                    <输入类型=文本名称=achternaam/>
                < /李>                <立GT;
                    <标签=telefoon> Telefoon Nummer< /标签>
                    <输入类型=文本名称=telefoon/>
                < /李>
                <立GT;
                    <标签=电子邮件>电子邮件住址< /标签>
                    <输入类型=文本名称=电子邮件/>
                < /李>
                <立GT;
                    <标签=bericht>类型票数JE bericht< /标签>
                    < textarea的名字=bericht>< / textarea的>
                < /李>
                <立GT;
                    <输入名称=提交类型=提交值=提交/>
                    <输入名称=复位TYPE =复位值=复位/>
                < /李>            < / OL>            < /表及GT;

和PHP的:

 < PHP$ voornaam = $ _ POST ['voornaam'];
$ achternaam = $ _ POST ['achternaam'];
$ telefoon = $ _ POST ['telefoon'];
$电子邮件= $ _ POST [电子邮件];
$ bericht = $ _ POST ['bericht'];$到=felicevancuyk@gmail.com;
$主题=DKL GROEP bericht。电子邮件($到,$主题,$ bericht,从$ voornaam $ achternaam $ telefoon};
回声Bedankt我们nemen ZO SNEL mogelijk接触会见ü运。?>


解决方案

这可能是因为你的动作不正确设置:

 <形式方法=邮报行动=联系形式NAME =联系形式ID =联系形式>

此动作标签是形式发送到URL。在你给上面的例子中,它不会出现是一个文件名。你希望它是这样的:

 <形式方法=邮报行动=htt​​p://mysite.com/process-form.phpNAME =联系形式ID =联系形式>

另外请注意,在您的示例PHP code您发送电子邮件到表单回复不需清洗这些反应。有人可能会发送恶意code到您的服务器,如果你不先清理数据。

是这样的:

  $ cleaned_voornaam = preg_replace(/ [^ 0-9A-ZA-Z] /,_,$ _ POST ['voornaam']);

祝你好运!

I'm working on my second website and throughout creating this one and my first the people here on StackOverflow have been an amazing help. I can just browse and find almost anything I wan't to know. 99% of problems I've had, I fixed with answers I've read on here. So first of thank you all so much!

This is the first time I'm posting something because I'm not able to find the specific answer for my code. There are people one here with the same problems but when I look at their code I'm just lost. I know html a fair bit by now. It's the php that I'm clueless about. I'm not looking for something fancy, I'm just trying to create a simple contact form.

So here is my question and code, I hope some of you are able to help me.

I used an PHP code from a youtube tutorial and it's deadeasy (as said before: first time PHP) yet I can't get it to work. Although I'm doing everything the same as the man in the clip. He shows his is working so I'm extremely curious as to way mine is not?

My form does not 'send' and after clicking the submit button I don't get the 'thank you' line.

here is the html:

<form method="post" action="contactform" name="contactform" id="contactform">

            <ol>
                <li>
                    <label for="voornaam">Voornaam</label>
                    <input type="text" name="voornaam" />
                </li>
                <li>
                    <label for="achternaam">Achternaam</label>
                    <input type="text" name="achternaam" />
                </li>

                <li>
                    <label for="telefoon">Telefoon Nummer</label>
                    <input type="text" name="telefoon" />
                </li>
                <li>
                    <label for="email">E-mail Adres</label>
                    <input type="text" name="email" />
                </li>
                <li>
                    <label for="bericht">Type hier je bericht</label>
                    <textarea name="bericht"></textarea>
                </li>
                <li>
                    <input name="submit" type="submit" value="submit" />
                    <input name="reset" type="reset" value="reset" />                    
                </li>

            </ol>

            </form>

and the PHP:

<?php

$voornaam = $_POST ['voornaam'];
$achternaam = $_POST ['achternaam'];
$telefoon = $_POST ['telefoon'];
$email = $_POST ['email'];
$bericht = $_POST ['bericht'];

$to = "felicevancuyk@gmail.com";
$subject = "dkl groep bericht";

mail ($to, $subject, $bericht, "From " . $voornaam . $achternaam . $telefoon};
echo "Bedankt. We nemen zo snel mogelijk contact met u op.";

?>

解决方案

It could be that your action is not set correctly:

<form method="post" action="contactform" name="contactform" id="contactform">

This action tag is the URL that the form is sent to. In the above example you gave, it doesn't appear to be a file name. You want it to be something like this:

<form method="post" action="http://mysite.com/process-form.php" name="contactform" id="contactform">

Also note that in your example PHP code you are emailing responses to the form without cleaning those responses. Someone could send malicious code to your server if you don't clean the data first.

Something like:

$cleaned_voornaam = preg_replace("/[^ 0-9a-zA-Z]/", "_", $_POST['voornaam']);

Good luck!

这篇关于提交按钮,我的联系形式不提交和重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆