Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用HTML表单通过PHP发送MySQL表_Php_Html_Mysql_Forms_Email - Fatal编程技术网

使用HTML表单通过PHP发送MySQL表

使用HTML表单通过PHP发送MySQL表,php,html,mysql,forms,email,Php,Html,Mysql,Forms,Email,有人能帮我修改代码吗 我想基于HTML表单检索数据库中的一些数据,并通过电子邮件(PHP)发送 HTML表单:(此表单工作正常,我看这里没有任何问题) 致: 任务状态: PHP:(我在另一个页面上使用这段代码作为函数,它似乎也可以正常工作,虽然有点不同,但可以正常工作) 在脚本顶部定义一个变量 $table='' 在循环中,在回显旁边,将字符串指定给变量: echo ' “.$setor。” “什么?” “.$截止日期。” “.$taskho。” “.$statusAb。” '; $

有人能帮我修改代码吗

我想基于HTML表单检索数据库中的一些数据,并通过电子邮件(PHP)发送

HTML表单:(此表单工作正常,我看这里没有任何问题)


致:
任务状态:
PHP:(我在另一个页面上使用这段代码作为函数,它似乎也可以正常工作,虽然有点不同,但可以正常工作)


  • 在脚本顶部定义一个变量

  • $table=''


  • 在循环中,在回显旁边,将字符串指定给变量:

  • echo
    '
    “.$setor。”
    “什么?”
    “.$截止日期。”
    “.$taskho。”
    “.$statusAb。”
    ';
    $table.=“”
    . ""
    . “$setor”
    . “$task什么
    
  • 在脚本顶部定义一个变量

  • $table='';


  • 在循环中,在回显旁边,将字符串指定给变量:

  • echo
    '
    “.$setor。”
    “什么?”
    “.$截止日期。”
    “.$taskho。”
    “.$statusAb。”
    ';
    $table.=“”
    . ""
    .“$setor”
    
    .“$task您可以发布一些您收到的错误吗?请查看phpMailer。你需要包括图书馆。下面是一个html联系人表单的示例,我不知道如何将该信息显示到电子邮件脚本中。我认为我的HTML和PHP工作得很好。字符串就是字符串就是字符串。如果要发送数据库结果,请将其分配给字符串而不是回音,然后将其插入电子邮件的html中。Ralph,我从html表单中获取值,并将其与PHP一起使用,从MySQL检索一些数据。但是我不知道如何在邮件中显示它们。你能发布一些你收到的错误吗?看看phpMailer。你需要包括图书馆。下面是一个html联系人表单的示例,我不知道如何将该信息显示到电子邮件脚本中。我认为我的HTML和PHP工作得很好。字符串就是字符串就是字符串。如果要发送数据库结果,请将其分配给字符串而不是回音,然后将其插入电子邮件的html中。Ralph,我从html表单中获取值,并将其与PHP一起使用,从MySQL检索一些数据。但我不知道如何在邮件中显示它们。非常感谢你们!你救了我的命呵呵:)非常感谢你们!你救了我的命呵呵:)
    <form method="post" action="valid_tasks.php">
    
        <div class="form-group">
            <label for="mailTo">To:</label>
            <select class="form-control" id="mailTo" name="mailTo">
                <?php echo showUsers(); ?>
            </select>
        </div>
    
        <div class="form-group">
            <label for="statusTo">Task Status:</label>
            <select class="form-control" id="statusTo" name="statusTo">
                <?php echo showStatus(); ?>
            </select>
        </div>
    
        <input type="submit" name="submitMail" id="submitMail" class="btn btn-info" value="Send" style="margin-bottom: 20px;">
    
    </form>
    
    <?php 
    
    require_once('db.class.php');
    
    $objDb = new db();
    $link = $objDb->conecta_mysql();
    
    if(isset($_POST['submitMail']))
        {
    
        $status = $_POST['statusTo'];
        $userMail = $_POST['mailTo'];
    
        $id = $_SESSION['id'];
        $username = $_SESSION['username'];
    
        $query = "SELECT T.setor, T.taskWhat, T.taskWho, DATE_FORMAT(T.deadLine,'%d/%m/%Y') AS deadLine,";
        $query .= "T.taskStatus, U.username, U.email, S.descricao, S.abDescri";
        $query .= "FROM tarefas AS T LEFT JOIN status AS S ON T.taskStatus = S.abDescri ";
        $query .= "LEFT JOIN users AS U ON U.username = T.taskWho ";
        $query .= "WHERE T.taskWho = '$userMail' AND S.abDescri = '$status'";
    
        $result = mysqli_query($link, $query);
    
    while($row = mysqli_fetch_assoc($result)){
    
        $setor = $row['setor'];
        $taskWhat = $row['taskWhat'];
        $taskWho = $row['taskWho'];
        $deadLine = $row['deadLine'];
        $taskStatus = $row['taskStatus'];
        $userAcao = $row['username'];
        $emailAcao = $row['email'];
        $statusDescri = $row['descricao'];
        $statusAb = $row['statusAb'];
    
        $setor = mysqli_escape_string($link, $setor);
        $taskWhat = mysqli_escape_string($link, $taskWhat);
        $taskWho = mysqli_escape_string($link, $taskWho);
        $deadLine = mysqli_escape_string($link, $deadLine);
        $taskStatus = mysqli_escape_string($link, $taskStatus);
        $userAcao = mysqli_escape_string($link, $userAcao);
        $emailAcao = mysqli_escape_string($link, $emailAcao);
        $statusDescri = mysqli_escape_string($link, $statusDescri);
        $statusAb = mysqli_escape_string($link, $statusAb);
    
        echo 
        '<tr>
            <td>'.$setor.'</td>
            <td>'.$taskWhat.'</td>
            <td>'.$deadLine.'</td>
            <td>'.$taskWho.'</td>
            <td>'.$statusAb.'</td>
        </tr>';
    
        }
    }
    
    $to = $email;
    $subject = "Tarefas com status ".$status;
    
    $message = "
    <html>
    <head>
    <title>HTML email</title>
    <link rel='stylesheet' type='text/css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
    </head>
    <body>
    <div class='container'>
    <center><h1>Hello, ".$username."!</h1></center>
    </div>
           // I NEED TO PUT THIS INFO HERE
    </div>
    </body>
    </html>
    
    echo 
    '<tr>
        <td>'.$setor.'</td>
        <td>'.$taskWhat.'</td>
        <td>'.$deadLine.'</td>
        <td>'.$taskWho.'</td>
        <td>'.$statusAb.'</td>
    </tr>';
    
    $table .= ""
        . "<tr>"
            . "<td>$setor</td>"
            . "<td>$taskWhat</td"
            . "<td>...</td>"
        . "</tr>"
    ;
    
     $message = "
    <html>
    <head>
    <title>HTML email</title>
    <link rel='stylesheet' type='text/css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
    </head>
    <body>
    <div class='container'>
    <center><h1>Hello, $username!</h1></center>
    </div>
        $table
    </div>
    </body>
    </html>";