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
https://forums.phpfreaks.com/topic/285093-logon-page-issues/
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'

Link to comment
https://forums.phpfreaks.com/topic/285093-logon-page-issues/#findComment-1463859
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
https://forums.phpfreaks.com/topic/285093-logon-page-issues/#findComment-1463863
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
https://forums.phpfreaks.com/topic/285093-logon-page-issues/#findComment-1463874
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
https://forums.phpfreaks.com/topic/285093-logon-page-issues/#findComment-1463882
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.