Jump to content

Recommended Posts

Can anyone help me as to what this means?

 

Notice: Undefined index: logged_in in /home/students/phannum/public_html/n413/class/Login/login.inc.php on line 7 Fatal error: Call to undefined function issest() in /home/students/phannum/public_html/n413/class/Login/login.inc.php on line 10

 

Here is my code:

 

<?php
require_once('config.inc.php');
require_once('functions.inc.php');

session_start();

if ($_SESSION['logged_in'] == true) {
	redirect('#');
} else {
	if ((!issest($_POST['username'])) || (!issest($_POST['password'])) OR 
		(!ctype_alnum($_POST['username'])) ) {
		redirect('#');
	}

	$mysql = @new mysql($dbhost, $dbuser, $dbpwd, $dbname);

	if (mysqli_connect_errno()) {
		printf("Unable to connect to database: %s", mysqli_connect_error());
		exit();
	}

	$username = $mysqli->real_escape_string($_POST['username']);
	$password = $mysqli->real_escape_string($_POST['password']);

	$sql = "SELECT * FROM users WHERE username = '" . $username . "' AND password = '" . md5($password) . "'";

	$result = $mysqli->query($sql);

	if(is_object($result) && $result->num_rows == 1) {
		$_SESSION['logged_in'] = true;
		redirect('#');
	} else {
		redirect('#');
	}
}
?>

Thanks!

 

Link to comment
https://forums.phpfreaks.com/topic/288328-help-with-syntax/
Share on other sites

I think the handling of booleans also needs some practice. ;)

 

What exactly is

if ($some_var == true)

supposed to do?

 

Are you afraid that the variable itself somehow isn't true enough and needs some extra trueness? Then why stop there? Why not:

if (((($some_var == true) == true) == true) == true)

Maybe it's even truer now.

 

Personally, however, I'd simply test the value: ;)

if ($some_var)
Link to comment
https://forums.phpfreaks.com/topic/288328-help-with-syntax/#findComment-1478692
Share on other sites

@Jacques1:

I wouldn't beat him up too bad about that - I see it all the time, even by advanced users. But, that is a pet peeve of mine. Even worse is when I see someone use an if/else condition where there is no logic included for the if() condition and only the else condition because the user wasn't able to properly create the condition.

Link to comment
https://forums.phpfreaks.com/topic/288328-help-with-syntax/#findComment-1478761
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.