联络人表单/邮件正文中的php变量 [英] Php variable in contact form / message body

查看:63
本文介绍了联络人表单/邮件正文中的php变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个仅在某些表单字段上传递的联系表单,我想知道是否有人可以帮助他为什么?

I have a contact form that is only passing over some of the form fields and i wondered if anyone can help as to why?

html表单如下:

            <form enctype="multipart/form-data" method="post" action="referral.php" onsubmit="return submitForm()">
      <fieldset>
          <div class="field">
            <input name="name" id="name" type="text" class="validate" placeholder="Your Name" />
            <span class="form-msg" id="name-error">Please add your name</span>
          </div>
            <div class="field here-for-next-until">
              <input name="email" id="email" type="text" class="validate" placeholder="Your E-mail" class="text-input validate" />
              <span class="form-msg" id="email-error">Please add your e-mail address</span>
            </div>
            <div class="field">
              <input name="phone" id="phone" type="text" placeholder="Your Phone Number" class="text-input validate" />
              <span id="phone-error" class="form-msg" >Please add your phone number</span>
            </div>                        
            <div class="area here-for-next-until">
              <textarea name="message" id="message" class="text-input validate" placeholder="Introduce Yourself"></textarea><br/>
              <span class="form-msg" id="email-error">Please add an introduction to yourself</span>
              <input type="text" id="cap_val" name="cap_val" class="code validate" placeholder="Enter Code From Right"/>
              <img src="bin/captcha.php" id="cap"/><img src="images/refresh.jpg" id="cap-refresh" onclick="change_captcha()"/><br/>
            <span id="captcha-error" class="form-msg" >Please add the above code</span>
            <div class="clear here-for-next-until"></div>
          </div>
    </div>

   <div class="flt-lt w420">
    <h2 class="subheader">Client</h2>
          <div class="field">
            <input name="referralsname" id="name" type="text" class="validate" placeholder="Name" />
            <span class="form-msg" id="name-error">Please add your referrals name</span>
          </div>
            <div class="field here-for-next-until">
              <input name="referralsemail" id="email" type="text" class="validate" placeholder="E-mail address" class="text-input validate" />
              <span class="form-msg" id="email-error">Please add your referrals e-mail address</span>
            </div>
            <div class="field">
              <input name="referralsphone" id="phone" type="text" placeholder="Phone Number" class="text-input validate" />
              <span id="phone-error" class="form-msg" >Please add your referrals phone number</span>
            </div>                        
            <div class="area here-for-next-until">
              <textarea name="referralsmessage" id="message" class="text-input validate" placeholder="Introduce Yourself"></textarea><br/>
              <span class="form-msg" id="email-error">Please add an introduction to yourself</span>
            <div class="clear here-for-next-until"></div>
                        <div id="submit-holder">
              <input class="submit" type="submit" value="Submit"/>
              <input id="reset" class="submit" type="reset" value="Reset"/>
            </div>
          </div>
      </fieldset>
    </form>

基本上这是两个非常相似的并排共享提交按钮的联系方式

Basically this is two very similar contact forms side by side that share a submit button

发布后显示:

$owner_email = 'myemail.co.uk';
  $subject = A message from your site visitor ' . $_POST["name"];

  $messageBody = "\nVisitor: " . $_POST["name"] . "\n";
  $messageBody .= "Email Address: " . $_POST['email'] . "\n";
  $messageBody .= "Phone Number: " . $_POST['phone'] . "\n";
  $messageBody .= "Message: " . $_POST['message'] . "\n";

  $messageBody = "\nVisitor: " . $_POST["referralsname"] . "\n";
  $messageBody .= "Email Address: " . $_POST['referralsemail'] . "\n";
  $messageBody .= "Phone Number: " . $_POST['referralsphone'] . "\n";
  $messageBody .= "Message: " . $_POST['referralsmessage'] . "\n";

但是,当我提交表格时,onyl会得到一组详细信息(前四个$ messageBody)

However when I submit the form I onyl get one set of details (the first 4 $messageBody)

任何人都能提供的帮助将不胜感激。

Any help anyone could offer would be greatly appreciated.

再次感谢

David

推荐答案

更改:

$ messageBody = \nVisitor:。 $ _POST [ referralsname]。 \n;

收件人:

$ messageBody。= nnVisitor:。 $ _POST [ referralsname]。 \n;

。= 而不是 = ,您正在将值重新分配给$ messageBody而不是将其链接到$ messageBody)

(.= instead of =, you are re-assigning value to $messageBody instead of chaining it to $messageBody)

这篇关于联络人表单/邮件正文中的php变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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