doutou6803 2017-12-10 09:10
浏览 31

而不是将用户id发送到数据库的电子邮件

Been trying for hours anyways this form suppose to take my email that is being displayed and on submit inserts the details include email into database. Form

Instead of taking my 'email' it is taking my user id(auto increment) from user table and update that into feedback table.database

feedback.php

<?php   


$email =(isset($_SESSION['email']) ? $_SESSION['email'] : null);
$name='';$feedback=''; $topic=''; $details=''; 
$action =(isset($_POST['submit']) ? $_POST['submit'] : null);

if($action!=null) {                 

    $name =(isset($_POST['name']) ? $_POST['name'] : null);
    $feedback =(isset($_POST['feedback']) ? $_POST['feedback'] : null);
    $topic =(isset($_POST['topic']) ? $_POST['topic'] : null);
    $details =(isset($_POST['details']) ? $_POST['details'] : null)

    if($details==null) {
        echo "<br><p style='text-align:center;color:red'>Please fill up all text fields!</p>";
    }
    else {
        $query="insert into feedback values('','$email','$name','$feedback','$topic','$details','',null)";
        $result=mysql_query($query);


        echo "<br><p style='text-align:center;color:blue'>Successfully submit the feedback to system </p>";
        $feedback=''; $topic=''; $details=''; 
    }

    if( mysql_error()!="") {
        echo "<font style='text-align:center;color:red'>" . mysql_error() . "</font><br>"; 
    } 


}
?>


<form method="post" action="user_feedback.php">     
    <?php
    $email =(isset($_SESSION['email']) ? $_SESSION['email'] : null);
    $query="select * from user where id=$email";
    $result=mysql_query($query);
    $row = mysql_fetch_array($result);


    ?>
    <br>
    <table cellpadding="5">
            <tr><td style="width:150px">User Email</td><td><input type="text" name="email" value="<?php echo $row['email'] ?>" disabled style="width:200px;"  ></td></tr>
            <tr><td>User Name</td><td><input type="text" name="name" value="<?php echo $name ?>" style="width:300px;" ></td></tr>

    <tr><td>Feedback</td>
    <td>
        <select name="feedback" style="height:32px">            
        <option <?php if($feedback=="Inquiry") { echo 'selected'; } ?> >Inquiry</option>

        </select>
    </td>
    </tr>
    <tr><td>Feedback Topic</td><td><input type="text" name="topic" value="<?php echo $topic ?>" style="width:300px;" ></td></tr>
    <tr><td>Feedback Details</td><td><textarea type="comment" name="details" value="<?php echo $details ?>" style="width:500px;" ></textarea></td></tr>
    <tr><td></td><td><input type="submit" name="submit" value="Submit" class="tall"></td></tr>
    </table>


</form>
  • 写回答

1条回答 默认 最新

  • doukuizuo1795 2017-12-10 10:27
    关注

    Fixed it by using suggestion because there is was mixed up of login session between id and email on login page it self.

    <?php   
    
    //echo("{$_SESSION['id']}"."<br />");
    
    $email =(isset($_SESSION['id']) ? $_SESSION['id'] : null);  
    $name='';$feedback=''; $topic=''; $details=''; 
    $action =(isset($_POST['submit']) ? $_POST['submit'] : null);
    if($action!=null) {                 
    
        $name =(isset($_POST['name']) ? $_POST['name'] : null);
        $feedback =(isset($_POST['feedback']) ? $_POST['feedback'] : null);
        $topic =(isset($_POST['topic']) ? $_POST['topic'] : null);
        $details =(isset($_POST['details']) ? $_POST['details'] : null);
    
        if($topic==null || $details==null) {
            echo "<br><p style='text-align:center;color:red'>Please fill up all text fields!</p>";
        }
        else {
            $query="insert into feedback values('','$email','$name','$feedback','$topic','$details','',null)";
            $result=mysql_query($query);
    
    
            echo "<br><p style='text-align:center;color:blue'>Successfully submit the feedback to system </p>";
            $feedback=''; $topic=''; $details=''; 
        }
    
        if( mysql_error()!="") {
            echo "<font style='text-align:center;color:red'>" . mysql_error() . "</font><br>"; 
        } 
    
    
    }
    ?>  
    
    <form method="post" action="user_feedback.php">     
        <?php
        $email =(isset($_SESSION['email']) ? $_SESSION['email'] : null);
        $query="select * from user where id=$email";
        $result=mysql_query($query);
        $row = mysql_fetch_array($result);
    
    
        ?>
        <br>
        <table cellpadding="5">
                <tr><td style="width:150px">User Email</td><td><input type="text" name="email" value="<?php echo $row['email'] ?>" disabled style="width:200px;"  ></td></tr>
                <tr><td>User Name</td><td><input type="text" name="name" value="<?php echo $name ?>" style="width:300px;" ></td></tr>
    
        <tr><td>Feedback</td>
        <td>
            <select name="feedback" style="height:32px">            
            <option <?php if($feedback=="Inquiry") { echo 'selected'; } ?> >Inquiry</option>
    
            </select>
        </td>
        </tr>
        <tr><td>Feedback Topic</td><td><input type="text" name="topic" value="<?php echo $topic ?>" style="width:300px;" ></td></tr>
        <tr><td>Feedback Details</td><td><textarea type="comment" name="details" value="<?php echo $details ?>" style="width:500px;" ></textarea></td></tr>
        <tr><td></td><td><input type="submit" name="submit" value="Submit" class="tall"></td></tr>
        </table>
    
    
    </form>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据