drzb7969753 2012-06-08 10:45
浏览 12
已采纳

提交php表单

I'm writing a php code where the user enter various details and then submits them in a form. But, when I submit it, I'm getting this as an error:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'sifeiitd'@'localhost' (using password: NO) in /home/sifeiitd/public_html/wh.php on line 95

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/sifeiitd/public_html/wh.php on line 95

My php code is

<?php
                //include the connection file

                require_once('functions/connection.php');
                require_once('functions/functions.php');

                $display_query = mysql_query("SELECT * FROM eportal");

                    echo "<table id='pageTable'><thead><tr><th>Item code</th><th>Image</th><th>Description</th><th>Cost</th></tr></thead>";
                    echo "<tbody>";
                    while($row = mysql_fetch_array($display_query)){
                        print "<tr><td>".$row['itemid']."</td><td>"."</td><td>".$row['description']."</td><td>";
                        print "&#8377;".$row['cost']."</td></tr>";
                    }
                    echo "</tbody>";
                    echo "</table>";
                    mysql_close($connection);

            ?>
            <?php

            //save the data on the DB and send the email

            //If the user has submitted the form
            if($_POST['submit']){
                //protect the posted value then store them to variables
                $name = protect($_POST['name']);
                $email = protect($_POST['email']);
                $contact=protect($_POST['contact']);
                $itemid=protect($_POST['itemid']);
                $itemquantity=protect($_POST['itemquantity']);
                $ip = gethostbyname($_SERVER['REMOTE_ADDR']);
                $message = protect($_POST['message']);
                //Check if the username or password boxes were not filled in
                if(!$name || !$email || !$contact || !$itemid){
                    //if not display an error message
                    echo "<center>Fields marked with <strong>&#40; &#42; &#421</strong> are mandatory!</center>";
                    }else{
                    //if the were continue checking
                        $result = mysql_query("INSERT INTO `wh_order` (`name`, `email`, `contact`, `itemid`, `itemquantity`, `ip`,`message`) VALUES('".$name."','".$email."','".$contact."','".$itemid."','".$itemquantity."','".$ip."','".$message."')");
                         //send the email with the order
                         if($result)
                            {
                                //send the email

                                $to = "ps@xyz.com";
                                $subject = "New order for Weaving Hope";

                                //headers and subject
                                $headers  = "MIME-Version: 1.0
";
                                $headers .= "Content-type: text/html; charset=iso-8859-1
";
                                $headers .= "From: ".$name." <".$email.">
";

                                $body = "New contact<br />";
                                $body .= "Name: ".$name."<br />";
                                $body .= "Email: ".$email."<br />";
                                $body .= "Contact No.: ".$contact."<br />";
                                $body .= "Item Id: ".$itemid."<br />";
                                $body .= "Quantity: ".$itemquantity."<br />";
                                $body .= "Comment: ".$message."<br />";
                                $body .= "IP: ".$ip."<br />";

                                mail($to, $subject, $body, $headers);

                                //ok message

                                echo "Your message has been sent";
                            }
                        }
                    }
            ?>
  • 写回答

1条回答 默认 最新

  • dongxian0320 2012-06-08 10:47
    关注

    Access denied for user 'sifeiitd'@'localhost' (using password: NO)

    Looks like a pretty clear error to me. Check your mysql_connect() statement, probably in connection.php.

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

报告相同问题?

悬赏问题

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