Jump to content

need assistance with authenticating username and PW


webguync

Recommended Posts

Then the records do not exist. Are you sure all field names are correct?

 

Try this...

 

<?php

error_reporting(E_ALL); ini_set('display_errors','1');

if (isset($_POST['Submit'])) {
  //connect to MySQL and select database to use
  //set up database and table names
  $db_name ="shadowdata";
  $table_name ="RegistrationForm";

  // connect to MySQL and select database to use
  $connection = mysql_connect("localhost","username","password") or die(mysql_error());
  $db = mysql_select_db($db_name) or die(mysql_error());

  $username = mysql_real_escape_string($_POST['loginemail']);
  $userpw = mysql_real_escape_string($_POST['loginpw']);
  $sql = "SELECT loginemail,loginpw FROM RegistrationForm WHERE loginemail = '$username' AND loginpw = '$userpw'";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      session_start();
      $_SESSION['logged'] = true;
      header("Location: console.php");
    } else {
      header("Location: index.php?error=x");
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }
}

?>

Link to comment
Share on other sites

for some reason I am still just getting a blank white page even though errors should be displaying. Not sure where the error is. Any help?

 


<?php

error_reporting(E_ALL); ini_set('display_errors','1');

if (isset($_POST['Submit'])) {
  //connect to MySQL and select database to use
  //set up database and table names
  $db_name ="shadowdata";
  $table_name ="RegistrationForm";

  // connect to MySQL and select database to use
  $connection = mysql_connect("localhost","username","PW") or die(mysql_error());
  $db = mysql_select_db($db_name) or die(mysql_error());

  $username = mysql_real_escape_string($_POST['loginemail']);
  $userpw = mysql_real_escape_string($_POST['loginpw']);
  $sql = "SELECT loginemail,loginpw FROM RegistrationForm WHERE loginemail = '$username' AND loginpw = '$userpw'";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      session_start();
      $_SESSION['logged'] = true;
      header("Location: console.php");
    } else {
      header("Location: index.php?error=x");
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }
}

?>

Link to comment
Share on other sites

Were going to need to place some echo's in the script to debug.

 

<?php

error_reporting(E_ALL); ini_set('display_errors','1');
echo "script called<br />"
if (isset($_POST['Submit'])) {
  echo "Within the if<br />";
  //connect to MySQL and select database to use
  //set up database and table names
  $db_name ="shadowdata";
  $table_name ="RegistrationForm";

  // connect to MySQL and select database to use
  $connection = mysql_connect("localhost","username","PW") or die(mysql_error());
  $db = mysql_select_db($db_name) or die(mysql_error());

  $username = mysql_real_escape_string($_POST['loginemail']);
  $userpw = mysql_real_escape_string($_POST['loginpw']);
  $sql = "SELECT loginemail,loginpw FROM RegistrationForm WHERE loginemail = '$username' AND loginpw = '$userpw'";
  if ($result = mysql_query($sql)) {
    echo "Query success<br />";
    if (mysql_num_rows($result)) {
      echo "Match found<br />";
      session_start();
      $_SESSION['logged'] = true;
      //header("Location: console.php");
    } else {
      echo "No match found<br />";
      //header("Location: index.php?error=x");
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }
}

?>

 

What does that produce?

Link to comment
Share on other sites

login.php

 

can be found here:

 

http://www.shadowmarket.com/real-estate/x/login.php

 

here is the form script

 

<?
include('x.php');
$error = $_REQUEST['error'];
?><br>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<?
include('header_admin.php')
?>
<body>
<div align="center">
  <table width="750" border="1" align="center" cellpadding="0" bordercolor="#000000" bgcolor="#FFFFFF">
    <tr>
      <td bordercolor="#FFFFFF"><div align="center">
        <table width="750" border="0" align="center" cellpadding="5" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
          <tr>
            <td colspan="2"><div align="center"><img src="../template_images/x_top.gif" width="750" height="75"></div></td>
          </tr>
          <tr>
            <td colspan="2" valign="top"><? include('menu.php'); ?></td>
          </tr>
	  <?
 if($logout)
   {
   print"<tr bgcolor='#CCFF00'>";
   }
   elseif($error)
   {
   print"<tr bgcolor='#FF0000'>";
   }
else
   {
print"<tr>";
   }

   ?>
            <td colspan="2" valign="top"><div align="center">
              <table width="100%"  border="1" align="center" cellpadding="0" bordercolor="#999999" bgcolor="#FFFFFF">
                <tr>
                  <td valign="top" bordercolor="#FFFFFF" bgcolor="#eeeeee"><div align="center" class="style1">System Administration
                      <? include('xver.txt');?>
Console</div></td>
                </tr>
              </table>
              <form action="login.php" method="post" name="xconsole" id="xconsole">
              <table width="100%"  border="1" align="center" cellpadding="0" bordercolor="#999999" bgcolor="#FFFFFF">
                <tr>
                  <td width="25%" bordercolor="#FFFFFF"><div align="right" class="style4">                    	 <?
				if($logout == "x")
   {
   print"<b>Log Out X Console = Success !</b>";
   }
   if($error)
   {
   print"<b>X Console Login = Error !</b>";
   }
   					if($logout == "y")
   {
   print"<b>Log Out X Console = Success ! Login Updated</b>";
   }

   ?>
</div></td>
                  <td width="25%" bordercolor="#FFFFFF"><div align="right"><span class="style4">Email Address </span></div></td>
                  <td width="50%" bordercolor="#FFFFFF"><div align="left" class="style4">
                    <input name="loginemail" type="text" id="q">
                  </div></td>
                </tr>
                <tr>
                  <td colspan="2" bordercolor="#FFFFFF"><div align="right" class="style4">Password</div></td>
                  <td valign="top" bordercolor="#FFFFFF"><div align="left" class="style4">
                    <input name="loginpw" type="password" id="t">
                  </div></td>
                </tr>
              </table>
                  <br>
                  <input type="submit" name="Submit" value="X Console Login">
                  <br>
              </form> 
            </div></td>
          </tr>
          <tr>
            <td width="448"><div align="center" class="style9">
              <div align="left"><a href="http://www.listingagent.ca" target="_blank"> <? print"$fc"; ?> : Installed Version # <? include('ver.txt'); include('xver.txt');?></a></div>
            </div></td>
            <td width="290"><div align="center" class="style9">
              <div align="right"><a href="index.php"><? print"$x_console"; ?></a></div>
            </div></td>
          </tr>
        </table>
      </div></td>
    </tr>
  </table>
</div>
</body>
</html>


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.