doubi6215 2017-07-24 13:14
浏览 36


So I have this little php script which upon form completion sends the information to my email. I was able to make it work with one input, however, when trying to specify 3 different inputs, it won't go through.

I suspect that maybe I'm not specifying the inputs as I should with isset at the beginning of the if statement. I'm very new to php and appreciate all the help I can get, anyway here's the code.


    if (isset($_POST['name' && 'emailq' && 'message'])){
  $visitor_name = $_POST['name'];
  $visitor_email = $_POST['emailq'];
  $visitor_message = $_POST['message'];

  $email_from = "LightDesigns";
  $email_subject = "new quot";
  $email_body = "Name: " .$visitor_name."
Email: " .$visitor_email."


  $to = "";
  $headers = "From: $email_from 
  $headers .= "Reply-To: $visitor_email 
  $result = mail($to,$email_subject,$email_body,$headers);

$link_address = '';
if ($result){
    echo '<link href="css/phpcss.css" rel="stylesheet">';
    echo "<header></header>";
    echo '<h1>Thank You!</h1>';
    echo "<p>I'll get in contact with you shortly.</p>";

    echo '<link href="css/phpcss.css" rel="stylesheet">';
    echo "<header></header>";

<form action="quotform.php" method="POST" class="quote" name="quot">
        <h1>Get a quot</h1>
        <hr align="left" style="width: 82%;">
            <input type="text" placeholder="Name" class="form" autocomplete required name="name">
                        <input type="email" placeholder="Email Address" class="form" autocomplete required name="emailq"> 
            <textarea placeholder="Message" name="message"></textarea>
            <button class="button_1" type="submit" class="form"><span>Send</span></button>
  • 写回答

3条回答 默认 最新

  • dpbvpgvrhwxen3222 2017-07-24 13:17

    it's wrong

    if (isset($_POST['name' && 'emailq' && 'message'])){

    it means to AND together 'name', 'emailq' and 'message' values, which will be a logical TRUE and checked if the $_POST array has a value with the key TRUE

    what you need is

    if (isset($_POST['name']) && isset($_POST['emailq']) && isset($_POST['message'])){

    or you could use

    if (isset($_POST['name'], $_POST['emailq'],$_POST['message'])){

    as mentioned by Magnus Eriksson

    each has to be a separate logical expression which are then ANDed together

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 Mac虚拟机安装Windows,Windows中用idea跑项目,报错process finished with exit code -1073741819(0xc0000005) 如何解决?
  • ¥15 关于python爬虫返回js数据结构的处理
  • ¥15 ubuntu所用stm32标准库开发烧录没反映
  • ¥15 运维工程师(在职人员回答)
  • ¥15 python 爬虫问题
  • ¥15 Kmeans的趋势分析有会的吗
  • ¥20 R语言单细胞测序 对seurat对象进行标准化时出现问题
  • ¥15 Anaconda navigator updateor一直更新
  • ¥15 请问如何在matlab里使用raven工具?
  • ¥100 关于ios手游充值到一定金额,再点充值提示公众号的问题。