在我的 HTML 中使用下拉选项的 PHP 代码无法正常工作。我使用 POST 作为检索方法,它导致 404 消息

发布于 2025-01-09 01:34:08 字数 2992 浏览 1 评论 0原文

我是否不应该使用 POST 方法来获取员工的信息?我以前用过这个表格,当时它只有姓名、电子邮件和电话,效果很好。我是 PHP 新手,有点迷失。

我编辑了一些表单,这样它就不会永远持续下去,所以我对冗长的代码表示歉意(这是我的第一篇文章)我真的只是专注于将表单的下拉菜单转换为 PHP 因为我相信这是我真正的问题。

这是我的下拉 HTML(已编辑)

<form action="solutions_form.php" method="post" >
<div class="ai-s7-row2">
                        <label for="">phone</label>
                        <input type="text" name="phone" required="required" placeholder="Enter your phone">
                    </div>
                    
                    <div class="ai-s7-row2">
                    <label for="">website</label>
                        <input type="text" name="website" required="required" placeholder="Enter your website">
                    </div>
                    
                    <div class="ai-s7-row3 form-message-area">
                        <label for="">tell us a little about your business's compliance and/or regulartory needs</label>
                        <textarea name="message" required="required" placeholder="Enter your message"></textarea>
                    </div>
                    
                    <div class="ai-s7-row2">
                        <label for="employees">number of employees</label>
                    <div class="ai-s7-row3">
                     <select id="employees" name="employees">
        <option value=""> Pick an option</option>
        <option value="< 10"> &#60; 10</option>
        <option value="< 100">&#60; 100</option>
        <option value="< 1000">&#60; 1000</option><option value="> 1000">more than 1000</option>
      </select>
</div>
                        </div>
                    <div class="form-btn-bx">
                        <input type="submit" class="form-submit-btn" value="Submit">
                    </div>
                </form>
     
This what I have in my PHP

    /* Data Variables */

    $name = $_POST['name'];
    $email = $_POST['email'];
    $organization = $_POST['organizatioon'];
    $industry = $_POST['$industry'] ;
    $phone = $_POST['phone'];
    $website = $_POST['website'];
    $message = $_POST['message'];
    $employees = $_POST['employees'];
    $honeypot = $_POST['_honey'];
    
    
    
    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Email: $email <br>
    Organization: $organization <br>
    Industry: $industry <br>
    Phone: $phone <br>
    Website: $website <br>
    Message: $message <br>
    Employees: $employees <br>
    
    EOD;
    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body,
    $headers);


Am I not supposed to be using the POST method to obtain the information for the Employees? I used this form before when it was just name, email, and phone and it worked fine. I'm new to PHP and am a bit lost.

I edited a little bit of the form out so that it didn't go on forever so I apologize for the lengthy code (this is my first post) I'm really just focused on getting the dropdown menu of the form converted into PHP because I believe that is my real issue.

this is my dropdown HTML (edited)

<form action="solutions_form.php" method="post" >
<div class="ai-s7-row2">
                        <label for="">phone</label>
                        <input type="text" name="phone" required="required" placeholder="Enter your phone">
                    </div>
                    
                    <div class="ai-s7-row2">
                    <label for="">website</label>
                        <input type="text" name="website" required="required" placeholder="Enter your website">
                    </div>
                    
                    <div class="ai-s7-row3 form-message-area">
                        <label for="">tell us a little about your business's compliance and/or regulartory needs</label>
                        <textarea name="message" required="required" placeholder="Enter your message"></textarea>
                    </div>
                    
                    <div class="ai-s7-row2">
                        <label for="employees">number of employees</label>
                    <div class="ai-s7-row3">
                     <select id="employees" name="employees">
        <option value=""> Pick an option</option>
        <option value="< 10"> < 10</option>
        <option value="< 100">< 100</option>
        <option value="< 1000">< 1000</option><option value="> 1000">more than 1000</option>
      </select>
</div>
                        </div>
                    <div class="form-btn-bx">
                        <input type="submit" class="form-submit-btn" value="Submit">
                    </div>
                </form>
     
This what I have in my PHP

    /* Data Variables */

    $name = $_POST['name'];
    $email = $_POST['email'];
    $organization = $_POST['organizatioon'];
    $industry = $_POST['$industry'] ;
    $phone = $_POST['phone'];
    $website = $_POST['website'];
    $message = $_POST['message'];
    $employees = $_POST['employees'];
    $honeypot = $_POST['_honey'];
    
    
    
    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Email: $email <br>
    Organization: $organization <br>
    Industry: $industry <br>
    Phone: $phone <br>
    Website: $website <br>
    Message: $message <br>
    Employees: $employees <br>
    
    EOD;
    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body,
    $headers);


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓬勃野心 2025-01-16 01:34:08

需要添加form,method = "post" action = 'PHP文件地址'

Need to add form,method = "post" action = 'PHP file address'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文