douhe2305 2019-02-02 06:55
浏览 31
已采纳

PHP表单给出错误

  This is my PHP code which I'm using and Error is coming between the First Echo command in the code. Can anyone please Help?
<?php
        if(isset($_POST["submit"])){
        // Checking For Blank Fields..
        if($_POST["name"]==""||$_POST["email"]==""||$_POST["phone_number"]==""||$_POST["city"]==""||$_POST["gre_score"]==""||$_POST["toefl_score"]==""||$_POST["eng_marks"]==""||$_POST["country"]==""||$_POST["course_type"]==""||$_POST["department"]==""||$_POST["exp"]==""||$_POST["ug_details"]==""||$_POST["pg_details"]){
        echo "Something Went Please Try Again!";
        }else{
        // Check if the "Sender's Email" input field is filled out
        $email=$_POST['email'];
        // Sanitize E-mail Address
        $email =filter_var($email, FILTER_SANITIZE_EMAIL);
        // Validate E-mail Address
        $email= filter_var($email, FILTER_VALIDATE_EMAIL);
        if (!$email){
        echo "Invalid Sender's Email";
        }
        else{
        $name = '$name';
        $subject = 'Registration Form';
        $headers = 'From: '. $email . "
"; // Sender's Email
        $headers .= 'Cc:'. $email . "
"; // Carbon copy to Sender
        $headers .= "MIME-Version: 1.0
";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1
";
        // Message lines should not exceed 70 characters (PHP rule), so wrap it
                  $message = '<html><body>';

                  $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
                  $message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
                  $message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
                  $message .= "<tr><td><strong>Phone Number:</strong> </td><td>" . strip_tags($_POST['phone_number']) . "</td></tr>";
                    $message .= "<tr><td><strong>City: </strong></td><td>" . strip_tags($_POST['city']) . "</td></tr>";
                  $message .= "<tr><td><strong>GRE Score:</strong> </td><td>" . strip_tags($_POST['gre_score']) . "</td></tr>";
                  $message .= "<tr><td><strong>TOEFL/IELTS Score:</strong> </td><td>" .  strip_tags($_POST['toefl_score']) .

""; $message .= "Engineering Marks: " . strip_tags($_POST['eng_marks']) . ""; $message .= "Country Planning: " . strip_tags($_POST['country']) . ""; $message .= "Department: " . strip_tags($_POST['department']) . ""; $message .= "Job Experience: " . strip_tags($_POST['exp']) . ""; $message .= "Under Graduation Details: " . strip_tags($_POST['ug_details']) . ""; $message .= "Post Graduation Details:" . strip_tags($_POST['pg_details']) . ""; $message .= "Course Selected: " . strip_tags($_POST['course_type']) . "";

                  $message .= "</body></html>";

        // Send Mail By PHP Mail Function
        mail("yash119ambaskar@gmail.com", $subject, $message, $headers);
        echo "Your mail has been sent successfuly ! You will be contacted Shortly!";
        }
        }
        }
        ?>
  • 写回答

1条回答 默认 最新

  • douyun1972 2019-02-02 07:18
    关注

    Hello Syntax error in your first if condition.Your post pg_details, you have not compare it with empty string.

            if($_POST["name"]==""||$_POST["email"]==""||$_POST["phone_number"]==""||$_POST["city"]==""||$_POST["gre_score"]==""||$_POST["toefl_score"]==""||$_POST["eng_marks"]==""||$_POST["country"]==""||$_POST["course_type"]==""||$_POST["department"]==""||$_POST["exp"]==""||$_POST["ug_details"]==""||$_POST["pg_details"] == ""){
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配