Jump to content

Help with Syntax?


PHannum

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

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.