dongzhenju3015 2018-07-21 16:28
浏览 74
已采纳

如何在我的注册表单中修复此错误

Warning: Cannot modify header information - headers already sent by (output started at /home/rsegomyu/public_html/registrations/userregister_action.php:42) in /home/rsegomyu/public_html/registrations/userregister_action.php on line 116

My site now online but fist time i fill the register form it's successfully registered but after i add my form to date-time field.some one fill this form and hi submit the form then register date and time automatically save in my database. but my website going on server but server sql time and my pc current time is different.but i contact host company and they create some page and they say now check it.but it's not work. And other error is i write some scrip to popup the message to show the registration successful then after this error message came.place help my some one thank you

this is my registration.php page code

<!DOCTYPE html>
<html lang="en">
<head>
 <title></title>
 <meta charset="utf-8">
    <link rel="stylesheet" href="css/reset.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/grid.css" type="text/css" media="screen">
    <script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="js/jquery.galleriffic.js" type="text/javascript"></script>
    <script src="js/jquery.opacityrollover.js" type="text/javascript"></script>
    <script src="js/jquery.nicescroll.js"></script>
<script>
    $(document).ready(
        function() { 
    $("html").niceScroll();
    }
    );
    </script><!-- nice scroll end-->
</head>
<body id="page1">
    <!--==============================header=================================-->
    <header>
        <div class="row-1">
            <div class="main">
                <div class="container_12">
                    <div class="grid_12">
                        <nav>
                            <ul class="menu">
                                <li><a  href="index.php">About Us</a></li>
                                <li><a href="catalogue.html">Catalogue</a></li>
                                <li><a  href="contacts.php">Contacts</a></li>
                                <li><a class="active" href="registration.php">Registration</a></li>
                            </ul>
                        </nav>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
        <div class="row-2">
            <div class="main">
                <div class="container_12">
                    <div class="grid_9">
                        <h1>
                            <a class="logo" href="index.html">1<strong>2</strong>4Docs</a>
                            <span>Design</span>
                        </h1>
                    </div>
                    <div class="grid_3">
                        <!--<form id="search-form" method="post" enctype="multipart/form-data">
                            <fieldset>
                                <div class="search-field">
                                    <input name="search" type="text" />
                                  <a class="search-button" href="#" onClick="document.getElementById('search-form').submit()"><span>search</span></a>
                                </div>
                            </fieldset>
                        </form>-->
                     </div>
                     <div class="clear"></div>
                </div>
            </div>
        </div>
    </header>
<!-- content -->
    <section id="content">
        <div class="bg-top">
            <div class="bg-top-2">
                <div class="bg">
                    <div class="bg-top-shadow">
                        <div class="main">
                            <div class="container_12">
                                <div class="wrapper">
                                    <article class="grid_12">
                                        <h3 class="color-1">Registration Form</h3>
                                        <div class="wrapper">
                   <!--message Box-->
                   <div style="color:#090; font-size:14px; text-align:center;">
            <?php
                        if(isset($_REQUEST['msg'])) {
                    echo base64_decode($_REQUEST['msg']);
                    }
                    ?>
                    </div>
                     <!--message Box-->
               <form id="contact-form" class="form-group" method="post" enctype="multipart/form-data" action="registrations/userregister_action.php">
                <label id="lbl"><span class="text-form2">Full Name</span>
                <input class="form-control" placeholder="Full Name" name="fullname" required/></label>
                <label id="lbl"><span class="text-form2">Address</span>
                <input class="form-control" placeholder="Address" name="address" required/></label>
                <label id="lbl"><span class="text-form2">Email</span>
                <input class="form-control" placeholder="Email" name="email" required/></label>
                 <label id="lbl"><span class="text-form2">NIC</span>
                <input class="form-control" placeholder="NIC" name="nic" required/></label>
                <label id="lbl"><span class="text-form2">Telephone No</span>
                <input class="form-control" placeholder="Telephone No" name="telephone_no" required/></label>
                <label id="lbl"><span class="text-form2">Loan Type</span>
                <select class="form-control" name="loantype" required="required">
                <option value="">Please Select Your Loan Type</option>
                <option value="Home">Home Loan</option>
                <option value="Personal">Personal Loan</option>
                </select></label>
                <label id="lbl"><span class="text-form2">Bank</span>
                <select class="form-control" name="bank" required="required">
                <option value="">Please Select Bank</option>
                <option value="BOC">BOC</option>
                <option value="NSB">NSB</option>
                <option value="RDB">RDB</option>
                <option value="PEOPLES">People's Bank</option>
                <option value="SEYLAN">Seylan</option>
                </select></label>
                <label id="lbl"><span class="text-form2">Loan Value (Laks)</span>
                <input class="form-control" placeholder="Amount" name="amount" required/></label>
                <label id="lbl"><span class="text-form2">Upload Your Plan Images (.pdf)</span>
                <input class="form-control" type="file" name="plan_file" required/></label>
                <p id="adslip">Advance Slip</p>
                <label id="lbl"><span class="text-form2">Payment Slip Upload (.png or .jpeg)</span>
                <input class="form-control" type="file" name="payment_slip_url" required/></label>
                <div class="buttons">
                <input class="form-control" type="submit" value="REGISTER" id="btn" onclick="myFunction()">
                <input class="form-control" type="reset" value="CLEAR" id="btn">
            </form>
                </div>
                      </div>
                                    </article>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!--==============================footer=================================-->
    <footer>
        <div class="main">
            <div class="container_12">
                <div class="wrapper">
                    <div class="grid_6">
                        <div>OneTwoFour-Docs &copy; 2018 <a class="link color-3" href="#">Privacy Policy</a></div>
                    </div>
                    <div class="grid_6" align="right">
                    Created By PerlTech Solutions
                    </div>
                </div>
            </div>
        </div>
    </footer>
    <script type="text/javascript">
            $(window).load(function() {
            // We only want these styles applied when javascript is enabled
            $('div.navigation').css({'width' : '320px', 'float' : 'right'});
            $('div.content').css('display', 'block');
            // Initially set opacity on thumbs and add
            // additional styling for hover effect on thumbs
            var onMouseOutOpacity = 0.5;
            $('#thumbs ul.thumbs li span').opacityrollover({
                mouseOutOpacity:   onMouseOutOpacity,
                mouseOverOpacity:  0.0,
                fadeSpeed:         'fast',
                exemptionSelector: '.selected'
            });
            // Initialize Advanced Galleriffic Gallery
            var gallery = $('#thumbs').galleriffic({
                delay:                     7000,
                numThumbs:                 12,
                preloadAhead:              6,
                enableTopPager:            false,
                enableBottomPager:         false,
                imageContainerSel:         '#slideshow',
                controlsContainerSel:      '',
                captionContainerSel:       '',
                loadingContainerSel:       '',
                renderSSControls:          true,
                renderNavControls:         true,
                playLinkText:              'Play Slideshow',
                pauseLinkText:             'Pause Slideshow',
                prevLinkText:              'Prev',
                nextLinkText:              'Next',
                nextPageLinkText:          'Next',
                prevPageLinkText:          'Prev',
                enableHistory:             true,
                autoStart:                 7000,
                syncTransitions:           true,
                defaultTransitionDuration: 900,
                onSlideChange:             function(prevIndex, nextIndex) {
                    // 'this' refers to the gallery, which is an extension of $('#thumbs')
                    this.find('ul.thumbs li span')
                        .css({opacity:0.5})
                },
                onPageTransitionOut:       function(callback) {
                    this.find('ul.thumbs li span').css({display:'block'});
                },
                onPageTransitionIn:        function() {
                    this.find('ul.thumbs li span').css({display:'none'});
                }
            });
        });
    </script>
</body>
</html>   

And this is my userregister_action.php code

<?php
session_start();
$msg="";
include 'db_connection.php';
$fullname=$_POST['fullname'];
$address=$_POST['address'];
$email=$_POST['email'];
$nic=$_POST['nic'];
$telephone_no=$_POST['telephone_no'];
$loantype=$_POST['loantype'];
$bank=$_POST['bank'];
$amount=$_POST['amount'];
$plan_file=basename($_FILES["plan_file"]["name"]);
$payment_slip_url=basename($_FILES["payment_slip_url"]["name"]);
$date=date('Y-m-d H:i:s');
//$job_description_img_url = basename($_FILES["job_description_img_url"]["name"]);
$sql= "INSERT INTO user_register (fullname,address,email,nic,telephone_no,loantype,bank,amount,plan_file,payment_slip_url,dateposted) VALUES ('$fullname','$address','$email','$nic','$telephone_no','$loantype','$bank','$amount','$plan_file','$payment_slip_url',NOW())";
//slip add START
        $folder = "payment_slip/";
        $file = $folder.basename($_FILES["payment_slip_url"]["name"]);
        //$success = move_uploaded_file($_FILES["payment_slip_url"]["tmp_name"],$file);
        $ok=1;
$file_type=$_FILES['payment_slip_url']['type'];
if ($file_type=="image/png" || $file_type=="image/jpeg") {
if(move_uploaded_file($_FILES['payment_slip_url']['tmp_name'], $file))
{
 echo "The file ". basename( $_FILES['payment_slip_url']['name']). " is uploaded";
}
else {
echo "Problem uploading file";
}
}
else {
echo "You may only upload JPEGs or PNG files.<br>";
//$msg=base64_encode("You may only upload JPEGs or PNG for Payment Slip");
}
//slip add END
//plan add START
$folder = "plans/";
$file = $folder.basename($_FILES["plan_file"]["name"]);
//$success = move_uploaded_file($_FILES["payment_slip_url"]["tmp_name"],$file);
$ok=1;
$file_type=$_FILES['plan_file']['type'];
if ($file_type=="application/pdf") {
if(move_uploaded_file($_FILES['plan_file']['tmp_name'], $file))
{
 echo "The file ". basename( $_FILES['plan_file']['name']). " is uploaded";
 }
 else {
 echo "Problem uploading file";
 }
}
else {
//echo "You may only upload PDFs.<br>";
$msg=base64_encode("You may only upload PDFs for Plan Images");
}
//plan add END
if (mysqli_query($dbcon,$sql)){
    //echo "OK";
    //$msg=base64_encode("Successfully Registered");
    $msg=base64_encode('Successfully Registered');
//}else{
    //echo "NO";
    //$msg=base64_encode("Please enter your details correctly");
//}
if($msg!=""){
//Redirection
header("Location:../registration.php?msg=$msg");
exit();
    }
}
else{
$msg=mysqli_error($dbcon);
}
?>

And This is the error show in my after the register

(The file user.png is uploadedThe file sheet 1.pdf is uploaded Warning: Cannot modify header information - headers already sent by (output started at /home/rsegomyu/public_html/registrations/userregister_action.php:42) in /home/rsegomyu/public_html/registrations/userregister_action.php on line 116)

  • 写回答

3条回答 默认 最新

  • duanmei1930 2018-07-21 16:40
    关注
    <?php
      ob_start();
        // your register.php script
      ob_end_flush();
    ?>
    

    let me know if problem persists.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效