dtll2016 2014-10-06 03:16
浏览 90
已采纳

包含html页面中的PHP echo或print语句的样式

Part of my validation script spits error codes depending on the error. It includes displaying an html error page. The statements that print or echo out on the error page always push the page down and also seem to affect some odd things like font size etc. It by default always displays the echo statements at the top of the page in the center. Is there a way I can style this? I would like the error message to display at a certain areas within the html?

if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
    echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
    echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
    echo "Email Address is a required field. Please enter it below.<br />";
}
include 'error_reg.htm'; 
exit(); 
}
  • 写回答

4条回答 默认 最新

  • drnbotxo449747 2014-10-06 03:41
    关注

    Actually its quite straightforward, in your echo, just add/wrap the html tag you desire on that message. The styling can be just as anything as you want it to look. And the placement of that error is also entirely up to you.

    Here is a super basic example:

    <!-- or just use an external css file -->
    <style type="text/css">
    .error-box {
        color:#555;
        font-family:Tahoma,Geneva,Arial,sans-serif;font-size:11px;
        padding:10px 10px 10px 36px;
        margin:10px;
        background-color: #ffecec;
        border:1px solid #f5aca6;
        width: 300px;
    
    }
    </style>
    <?php
    $first_name = '';
    if(!$first_name){
        echo "<div class='error-box'>First Name is a required field. Please enter it below.</div>";
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100