首页 > 解决方案 > Wordpress 自定义表单发布以将数据发送到另一个页面

问题描述

您好,我正在 Wordpress 中创建两个页面:dragdrop-translation.phptranslation-detail.php使用自定义模板。在第一个中,用户选择几种语言、一个截止日期和必须翻译的文件(.txt 或 .pdf)。应该将这些数据发送到,traslation-detail但我的 POST 操作有问题。模板放置在wp-content/themes/hello-theme-child-master/dragdrop-translation.phpwp-content/themes/hello-theme-child-master/translation-detail.php

包含 POST 表单的页面的代码是:

<?php
/**
* Template Name: Drag&Drop - Traslation
*
*/
get_header();?>
<div style="margin-top:120px;">
<!--FIRST PART OF FORM-->
<form method="POST" enctype="multipart/form-data" action="/translation-detail/">
<?php function show_languages_list(){
    global $wpdb;
    $table_name = "wp_languages_price";
    $prepared_query = $wpdb->prepare("SELECT * FROM ".$table_name."");
    $results = $wpdb->get_results($prepared_query );
    echo '<label for="'.'languages'.'">Select language:</label><select name="'.'languages'.'" id="'.'languages'.'">';
    echo '<option value="" disabled selected>Select languages</option>';
    foreach($results as $languageCouple){
        echo '<option>'.$languageCouple->languages_1.' - '.$languageCouple->languages_2.'</option>';
    }
    echo '</select>';
}
show_languages_list();?>
<label for="start">Deadline:</label>
<input type="date" id="date" name="trip-start"
       min="" max="" placeholder="yyyy-mm-dd">

<br>
<label>Insert text file</label>
<input type="file" name="datafile" id="datafile" size="40" required>
<br>
<input type="submit" value="Calcola preventivo" onclick="checkFields()">
</form>
<br>
<div id="errors" style="color: red;">
</div>
</div>
<script>
    //Script for check the datas removed
</script>
<?php get_footer();?>

translation-detail.php 的代码是空的所以我就不贴了。

当我提交数据时,服务器在帖子的操作文件夹上回复 404。我需要在表单的操作字段上放置什么路径?

标签: phpwordpressformspost

解决方案


推荐阅读