Page 2 of 2

Posted: Mon Oct 16, 2006 11:22 am
by volka
strange.
Maybe more debug output is helpful

Code: Select all

<?php
//Initiates php script containing functions all common functions
session_start();
require_once('common.php');
$dbconnect = db_connect();

//outputs header info to brower with the following title
echo xhtmlheader('Personal Account Registration Form');
 
//outputs the main navigation bar to the browser
echo topnav_pa();

if (isset($_POST['email']) && isset ($_POST['pwd']))
{
	//if the user has just tried to log in
	$email = $_POST['email'];
	$pwd = $_POST['pwd'];
 
	$sql = "select * from Authourised_User where userEmail='$email' and userPassword='$pwd'";
	
	echo '<div>Debug: ', date('d.M Y H:i:s'), "</div>\n"; flush();
	echo '<div>Debug: ', gettype($dbconnect), "</div>\n"; flush();
	echo '<div>Debug: ', htmlentities($sql), "</div>\n"; flush();
	$result=$dbconnect->query($sql);
	echo '<div>Debug: ', gettype($result), "</div>\n"; flush();
	if ( !$result) {
		echo '<div>error: ' , $dbconnect->error, "</div>\n"; flush();
	}
	else if ($result->num_rows >0 ) {
		echo "<div>Debug: valid user $email </div>\n"; flush();
		$_SESSION['valid_user'] = $email;
	}
	else {
		echo "<div>Debug: invalid user</div>\n"; flush();
	}
	$dbconnect->close();
}
?>
 
<!-- main body of page -->
<div id="main">
  <h1>My Pub Crawl Planner</h1>
 



<?php
  if (isset($_SESSION['valid_user']))
  {
    echo 'You are logged in as: '.$_SESSION['valid_user'].' <br />';
    echo '<a href="logout.php">Log out</a><br />';
  }
  else
  {
    if (isset($email))
    {
      // if they've tried and failed to log in
      echo 'Could not log you in.<br />';
    }
    else
    {
      // they have not tried to log in yet or have logged out
      echo 'You are not logged in.<br />';
    }
  }
?>
	
  <p>Member Login </p>

 <form action="index.php" method="post" class="login">         /****form action *****/

    <table>
      <tr>
        <td>E-mail:</td>
        <td class="table"> <input type="text"
                name="email"
                value=""
                tabindex="1"/></td>
      </tr>
      <tr>
        <td>Password:</td>
        <td class="table"> <input type="text"
                name="pwd"
                value=""
                tabindex="2"/></td>
      </tr>
(printf/echo debuggers are awful, but anyway ;))

Posted: Mon Oct 16, 2006 11:33 am
by garry27
no change. it also randomly swithcing between

Code: Select all

Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. 

If you think this is a server error, please contact the webmaster. 

Error 404
(and the php return error and page not found) when i hit submit

Posted: Mon Oct 16, 2006 11:42 am
by volka
8O
But that's complete different from
Notice: Trying to get property of non-object in /home/unn_p921847/public_html/index.php on line 24
404 is an error the webserver sends: there is no document/object at the requested url.
Notice: Trying to get property.... that's a message sent by php.


edit: just tried your link
garry27 wrote:and removing the css style functions:

http://www.nl-webspace.co.uk/~unn_p921847
When I press "login" the url http://www.nl-webspace.co.uk/~unn_p9218 ... 50230i8u15 is requested.
there's no ? between index.php and PHPSESSID=
Therefore the brwser requests the document index.phpPHPSESSID=jup2lmb0d3hb9hua50230i8u15
not the document index.php, sending the GET parameter PHPSESSID=jup2lmb0d3hb9hua50230i8u15

Posted: Mon Oct 16, 2006 11:44 am
by garry27
same.
page cannot be found
i have another php/mysql on the same route directory which works fine.

Posted: Mon Oct 16, 2006 11:46 am
by volka
*bump*
see "revised" version of last post

Posted: Mon Oct 16, 2006 11:55 am
by garry27
right, i've changed the form back so it now reads

Code: Select all

<form action="index.php" method="post" class="login">
and i get the following output:
Debug: 16.Oct 2006 17:45:40
Debug: object
Debug: select * from Authourised_User where userEmail='gkuygkyf' and userPassword='kyfkjy'
Debug: boolean
error: No database selected

Posted: Mon Oct 16, 2006 12:06 pm
by garry27
yay! i've fixed it.

is seems i needed to include the database name somewhere in the db connection string (which is also unn_p921847):

Code: Select all

return new mysqli('www.nl-webspace.co.uk', 'unn_p921847', 'password', 'unn_p921847');
it's odd that i never had to include this on previous coding i've done but anyway thanks a lot, mate! you've been really helpful.

Posted: Mon Oct 16, 2006 12:27 pm
by RobertGonzalez
In the future, can you please not post information related to the login creentials of your database? This is more for your security than anything. Thanks.