Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:28:44+00:00 2026-06-12T06:28:44+00:00

I have this file here: <?php include ‘core/init.php’; include ‘includes/overall/header.php’; if(empty($_POST) === false){ $required_fields

  • 0

I have this file here:

<?php 
    include 'core/init.php';
    include 'includes/overall/header.php';

    if(empty($_POST) === false){
        $required_fields = array('username','password','password_again','first_name','email');
        foreach($_POST as $key=>$value){
            if(empty($value) && in_array($key, $required_fields) === true){
                $errors[] = 'Fields Marked with an asterisk are required';
                break 1;
            }
        }   

        if(empty($errors) === true){
            $args = $_POST;
            if(user_exists($args['username'])){
                $errors[] = 'Sorry, the username \''.$args['username'].'\' is already in use.';
            }else if(preg_match("/\\s/",$args['username']) == true){
                $errors[] = 'Your username can not contain any spaces.';
            }
            if(strlen($args['password']) < 6){
                $errors[] = "Your Password is to short! It must be at least 6 characters. If you want to know why you need to use a better password visit this page, <a href=\"http://howsecureismypassword.net/\">password checker</a>.<br/>";
            }else if($args['password'] !== $args['password_again']){
                $errors[] = "Your passwords do not match!";
            }
            if(filter_var($args['email'], FILTER_VALIDATE_EMAIL) === false){
                $errors[] = "A valid email address is required.";
            } else if(email_exists($args['email']) === true){
                $errors[] = 'Sorry, the email \''.$args['email'].'\' is already in use.';
            }
        }

    }


?>
<h1>Register</h1>
<?php 
    if(empty($_POST) === true){
        include 'includes/register.php'; 
    }else if(empty($_POST) === false && empty($errors) === true){
        //Register user
        echo "Registered User";
    }else{
        echo output_errors($errors);
        include 'includes/register.php'; 
    }?>
<?php include 'includes/overall/footer.php';?>

Heres register.php:

<?php
    $username = "";
    $first_name = "";
    $last_name = "";
    $email = "";
    if(empty($_POST) === false){
        $username = $_POST['username'];
        $first_name = $_POST['first_name'];
        $last_name = $_POST['last_name'];
        $email = $_POST['email'];
    }
?>
<form action="" method="POST">
    <ul>
        <li>Username*: <br/><input type="text" name="username" value="<?php echo $username;?>"/></li>
        <li>Password*: <br/><input type="text" name="password"/></li>
        <li>Confirm Password*: <br/><input type="text" name="password_again"/></li>
        <li>First name*: <br/><input type="text" name="first_name" value="<?php echo $first_name;?>"/></li>
        <li>Last name: <br/><input type="text" name="last_name" value="<?php echo $last_name;?>"/></li>
        <li>Email*: <br/><input type="text" name="email" value="<?php echo $email;?>"/></li>
        <li><input type="submit" value="Register"/></li>
    </ul>
</form>

This isn’t ever going to be a real site, it’s just me playing around with PHP, what I realised is that when a user submits their data they can put in what ever they want, so if they put in some HTML, would it render as well? like… would they be able to put in the input field last_name a value like "<p>blah blah blah</p>", would this essentially render as

  • Last name:
    blah blah blah

    “”/>

  • Because wouldn’t that be kinda bad for the site? They could break it or something?

    So is there something that fixes this? Like replaces tags like < and > with &lt; and &gt; and makes " into \" or escapes these characters?

    Also… is there anything terribly wrong with my code?

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-06-12T06:28:45+00:00Added an answer on June 12, 2026 at 6:28 am

      What you need is this: http://php.net/manual/en/function.htmlentities.php

      htmlentities

      This function is identical to htmlspecialchars() in all ways, except
      with htmlentities(), all characters which have HTML character entity
      equivalents are translated into these entities.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I have a cron job that needs to include this file: require '../includes/common.php'; however,
    I have this code here: case 'resource_list': if(file_exists('content.php')){ include('../ajax/content.php'); } else { die('does not
    I have a PHP script like this: <?php include 'authorization_script.php'; foreach ($_POST as $key
    I have this xml file which has text init. i.e Hi my name is
    I have this header file, zeeheader.h, and I wrote some classes in it, I'm
    I have this file 'gardens.php' , which pulls data from a table called 'generalinfo'
    I have a php file that includes two functions, one to connect to the
    I have a trouble with include function, here is a problem: i have index.php
    I have this nginx vhost file server { # php/fastcgi listen 80; server_name trinityplex.com
    I have been having this issue when I use the php include() or require()

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.