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 8511635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:03:32+00:00 2026-06-11T04:03:32+00:00

I have the following php pahe which accepts the user’s first name and password

  • 0

I have the following php pahe which accepts the user’s first name and password to access a password protected site.

 <?php
    /**
     * ****************************************************************************
     * Micro Protector
     * 
     * Version: 1.0
     * Release date: 2007-09-10
     * 
     * USAGE:
     *   Define your requested password below and inset the following code
     *   at the beginning of your page:
     *   <?php require_once("microProtector.php"); ?>
     * 
     *   See the attached example.php.
     * 
     ******************************************************************************/


    $Password = 'testpass'; // Set your password here



    /******************************************************************************/
       if (isset($_POST['submit_pwd'])){
          $pass = isset($_POST['passwd']) ? $_POST['passwd'] : '';

          if ($pass != $Password) {
             showForm("Wrong password");
             exit();     
          }
       } else {
          showForm();
          exit();
       }

    function showForm($error="LOGIN"){
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
       <title>IMC - Authentication</title>
       <link href="style/style.css" rel="stylesheet" type="text/css" />
    <Script>
    <!--
    function capitalize(form) {
        value = form.value;
        newValue = '';
        value = value.split(' ');
        for(var i = 0; i < value.length; i++) {
            newValue += value[i].substring(0,1).toUpperCase() +
            value[i].substring(1,value[i].length) + '';
        }
    newValue = newValue.replace(/(<([^>]+)>)/ig,"");
    form.value = newValue;
    }
    -->
    </Script>
    </head>
    <body>
    <center><a href="http://www.test.com"><img src="http://www.test.com/topLogo.png" border=0 /></a></center>
    <br><br><br>
        <div id="main">
          <div class="caption"><?php echo $error; ?></div>
          <div id="icon">&nbsp;</div>
          <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="pwd">
        Your Name:
            <table>
              <tr><td><input class="text" name="name" onBlur="capitalize(this);" maxlength=12 type="text" /></td></tr>
            </table> 
            Password:
            <table>
              <tr><td><input class="text" name="passwd" maxlength=8 type="password" /></td></tr>
              <tr><td align="center"><br/>
                 <input class="text" type="submit" name="submit_pwd" value="Login" />
              </td></tr>
            </table>  
          </form>
       </div>
    </body>
    </html>

    <?php   
    }
    ?>

Currently it’s not validating any XSS or any type of malicious attack. On my contact us page, i have the following code which ensures the user cannot enter any XSS or any kind of malicious code:

// Clean up the input values 
foreach($_POST as $key => $value) { 
  if(ini_get('magic_quotes_gpc')) 
    $_POST[$key] = stripslashes($_POST[$key]); 

  $_POST[$key] = htmlspecialchars(strip_tags($_POST[$key])); 
}

Can anyone tell me where would I insert the above code in my php page to ensure no code is inserted for malicious intent.

  • 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-11T04:03:34+00:00Added an answer on June 11, 2026 at 4:03 am

    I would suggest using a library like HTMLPurifier. It is very easy to use and can filter the user input, preventing XSS attacks.

    $filter = new HTMLPurifier();
    
    foreach($_POST as $key => $value) { 
      $_POST[$key] = $filter->purify($_POST[$key])); 
    }
    

    then you can check the password against the one in your database or other storage mechanism

    HTH

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

Sidebar

Related Questions

I have following html form: <form method=post action=> <input type=hidden name=userid id=user value=<?php echo
I have the following PHP code which is attempting to check for password complexity
I have the following php which uploads image to server with name inserted in
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I have the following php code which I want to add a delay too:
I have the following PHP function which will list the users from a MySql
I have the following PHP code which simply grabs a URL behind HTTP-Basic authentication
I have the following PHP function: function func_name($name = 'John', $country = 'USA') {
I have the following PHP function function newUser($username, $password) { $checkUsernameAvailablity = check($username); if
I have the following PHP code to display the file structure of my site.

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.