Jump to content

Logon Page Issues.


suhail

Recommended Posts

I was trying to make a php logon page with root password only.

I declared the contents of the logon page with the following contents

 

config.php

<?php
define('hostname','localhost');
define('dbuser','root');
define('dbpass','rootpass123');
define('dbname','infos')

//define login credentials 

define('rootpass','rootuser1');

?>

Now i wanted to include it in my html i decide to include it in the main php file like this 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>login</title>
<style type="text/css">
<!--
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
}
-->
</style>
</head>

<body>
<?php
require_once(dirname(__FILE__) . "/config.php");
include 'config.php';
if(isset($_POST['submit']))
{
	if(rootpass!==rootpass1)
	{
		print"Wrong Password";
	}
	else{
		 header("Location: http://www.google.de");
	}
}
?>
<div align="center">
  <table width="559" border="0">
    <tr>
      <td width="553"> </td>
    </tr>
    <tr>
      <td><div align="center">
        <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"">
          <table width="459" border="0">
            <tr>
              <td width="164"><div align="center"><span class="style1">Root Password </span></div></td>
              <td width="245"><label>
                <input name="rootpass" type="password" id="rootpass" />
              </label></td>
            </tr>
            <tr>
              <td> </td>
              <td><label></label></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="submit" name="submit" value="login" /></td>
            </tr>
          </table>
          </form>
        </div></td>
    </tr>
  </table>
  <blockquote>
    <table width="1149" border="0">
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td><div align="center" class="style1">Soldier Bot © 2014 All Rights Reserved </div></td>
      </tr>
    </table>
</blockquote>
</div>
</body>
</html>

when i run it i get errors like this 

 

Logg.png

 

What could go wrong? 

Link to comment
Share on other sites

Too many things. Start with the path.

 

i am a newbie to this kind of stuff. How do i go about it, implemented code. Kindly show me. I would like to learn this. the config is included in this path

 

../config/config.php cos thats where the file is.

 

Do i include it like this 

 

include '../config/config.php'

Edited by suhail
Link to comment
Share on other sites

First, check how to find the computing path to the config.php file for your operating system (windows).

 

Second, don't try to include the same path twice in different variants! Use either include (include_once) or require (require_once).

 

Third, I don't see when you defined a rootpass1 constant in your script to compare the values with the rootpass constant.

Link to comment
Share on other sites

Ok i fixed one part.

but the part that checks for the rootpassword from the config.php file is giving me issues, i am lost somehow here is my code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>login</title>
<style type="text/css">
<!--
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
}
-->
</style>
</head>

<body>
<?php
include_once'C:\wamp\www\soldierbot\panel\config\config.php';
if(isset($_POST['submit']))
{
	$rootpass = $_POST['rootpass'];
	if(rootpass!==rootpass1)
	{
		print"Wrong Password";
	}
	else{
		 header("Location: http://www.google.de");
	}
}
?>
<div align="center">
  <table width="559" border="0">
    <tr>
      <td width="553"> </td>
    </tr>
    <tr>
      <td><div align="center">
        <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"">
          <table width="459" border="0">
            <tr>
              <td width="164"><div align="center"><span class="style1">Root Password </span></div></td>
              <td width="245"><label>
                <input name="rootpass" type="password" id="rootpass" />
              </label></td>
            </tr>
            <tr>
              <td> </td>
              <td><label></label></td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="submit" name="submit" value="login" /></td>
            </tr>
          </table>
          </form>
        </div></td>
    </tr>
  </table>
  <blockquote>
    <table width="1149" border="0">
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td><div align="center" class="style1">Soldier Bot © 2014 All Rights Reserved </div></td>
      </tr>
    </table>
</blockquote>
</div>
</body>
</html>

Pls help me.

Link to comment
Share on other sites

Ok,

 

Please just help me correct it. To check for the rootpass from the config.php and if it matches the password rootpass1 it should redirect to google(which should be the second page) or dashboard that's what I want it to do.

Link to comment
Share on other sites

You need to compare the value from "rootpass" constant and value from html input field, named - rootpass!

 

Try,

$rootpass = trim($_POST['rootpass']);

	if($rootpass != rootpass)
	{
		print"Wrong Password";
	}
	else{
		 header("Location: http://www.google.de");

                 exit; // don't forget to call the exit command to terminate the script
	}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.