繁体   English   中英

PHP代码出现在页面的标题部分

[英]PHP code appearing in header section of page

由于某些明显的原因,我的PHP代码的一部分显示在页面的标题部分。

在此处输入图片说明

我完全不知道为什么会这样。 我已经重新检查了所有变量,并测试了如何在IE和Firefox上分页渲染,但是发生相同的问题。

reg.php:

<?
$registration = @$_POST[`submitReg`];
// Getting all other info from form and assigning it to variables
$firstname    = strip_tags(@$_POST[`fname`]);
$lastname     = strip_tags(@$_POST[`lname`]);
$username     = strip_tags(@$_POST[`username`]);
$email        = strip_tags(@$_POST[`email`]);
$email2       = strip_tags(@$_POST[`email2`]);
$password     = strip_tags(@$_POST[`password`]);
$password2    = strip_tags(@$_POST[`password2`]);
$DOBDay       = strip_tags(@$_POST[`DOBDay`]);
$DOBMonth     = strip_tags(@$_POST[`DOBMonth`]);
$DOBYear      = strip_tags(@$_POST[`DOBYear`]);
$gender       = strip_tags(@$_POST[`gender`]);
$sign_up_date = date("d-m-Y"); // Sign up date is not getting any data from the form

if ($registration) {
if ($email==$email2) {

// If both emails match, then check if user already exists:
$u_check = mysqli_query("SELECT username FROM users WHERE username='$username'"); // Count the amount of rows where username = $username
$e_check = mysqli_query("SELECT email FROM users WHERE email='$email'"); //Check whether Email already exists in the database

// checking the amount of rows where username is equal to $username - avoid two users with same username - same idea for email
$check = mysqli_num_rows($u_check);
$email_check = mysqli_num_rows($e_check);
if ($check == 0) {
  if ($email_check == 0) {

 // If no matches found then: 1. check all fields are completed correctly:
 if ($firstname && $lastname && $username && $email && $email2 && $password && $password2 && $DOBDay && $DOBMonth && $DOBYear && $gender) {
 // 1.2. check that passwords match:
if ($password==$password2) {


-------------------- CODE WHICH IS APPEARING IN THE HEADER ---------------------
 // 1.2.1. Check fields are of valid length
    if (strlen($username) > 25 || strlen($firstname) > 25 || strlen($lastname) > 25 || strlen($password) > 25) {
    echo "The maximum character limit is 25."; 
    }
    else
    {
    // check the maximum length of password does not exceed 25 characters and is not less than 6 characters
    if (strlen($password)>25||strlen($password)<6) {
    echo "Your password must be between 6 and 25 characters long!";
    }
    else
    {
    // if everything correct, encrypt passwords using MD5 before sending it to server.
    $password = md5($password);
    $password2 = md5($password2);
    $query = mysqli_query("INSERT INTO users VALUES (``, `$firstname`, `$lastname`, `$username`, `$email`, `$password`, `$sign_up_date`)");
    die("<h2>Welcome to Aston Unified</h2> Login to your account to get started ...");
    }
    }
    }
    else {
    echo "Your passwords don't match!";
    }
    }
    else
    {
    echo "Please fill in all of the fields";
    }
    }
    else
    {
     echo "Sorry, but it looks like someone has already used that email!";
    }
    }
    else
    {
    echo "Username already taken ...";
    }
    }
    else {
    echo "Your E-mails don't match!";
    }
    }
_______________________________________________________________________
?>

关于为什么会发生这种行为的任何想法?

似乎PHP短标签<? 关闭,您已经使用了。 尝试使用<?php ,然后检查。

如果您需要使用该设置

short_open_tag=On

在php.ini中,然后重新启动Apache服务器。

您应该在php.ini中启用短标签(在php.ini中添加short_open_tag = On)或使用<?php代替<?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM