Jump to content
Larry Ullman's Book Forums

Pls Help Need Urgent Help. The .Inc Extension. Chapter 11


Recommended Posts

After typing †ђξ login_page.inc.php code ãήϑ storing it in †ђξ includes folder alongside †ђξ header.html, footer.html etc. But am still getting errors.

 

This is †ђξ code

 

Login_page.inc.php

 

<?php

$page_title = 'Login';

include ('includes/header.html');

 

//print error messages

 

if(!empty($errors))

{

echo '<h1>Error!</h1>

<p class = "error">The following error(s) occured:<br />';

 

foreach($errors as $msg )

{

echo " -$msg <br />\n";

}

echo '</p><p>Pls try again.</p>';

}

//display form

?>

<h1>Login</h1>

<form action="login.php" method= "post">

<p>Email Address: <input type= "text" name="email" size="20" maxlength="80" /> </p>

<p>Password: <input type="password" name="pass" size="20" maxlength="20" /></p>

<p><input type="submit" name="submit" value="Login" /></p>

<input type="hidden" name= "submitted" value="TRUE" />

</form>

<?php // Include the footer:

include ('includes/footer.html');

?>

 

Ãήϑ dis are †ђξ errors

 

( ! ) Warning: include(includes/header.html) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 3

Call Stack

#TimeMemoryFunctionLocation

10.0034370072{main}( )..\login_page.inc.php:0

 

( ! ) Warning: include() [function.include]: Failed opening 'includes/header.html' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 3

Call Stack

#TimeMemoryFunctionLocation

10.0034370072{main}( )..\login_page.inc.php:0

 

 

( ! ) Warning: include(includes/footer.html) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 87

Call Stack

#TimeMemoryFunctionLocation

10.0034370072{main}( )..\login_page.inc.php:0

 

( ! ) Warning: include() [function.include]: Failed opening 'includes/footer.html' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 87

Call Stack

#TimeMemoryFunctionLocation

10.0034370072{main}( )..\login_page.inc.php:0

Link to comment
Share on other sites

Yes I ws confusing it all sir. Thanks §☺ much.

Now having dis new problem. †ђξ login.php is giving me a error, which it says is on line 46 in my function_login.inc.php. This is †ђξ error

 

 Parse error: syntax error, unexpected ';' in C:\wamp\www\PHPPRACTICENEW\includes\login_function.inc.php on line 46 Call Stack#TimeMemoryFunctionLocation10.0016371904{main}( )..\login.php:0

 

This is †ђξ function_login.inc.php:

<?php

//this page defines 2 function used by login/logout process

 

/*This function determines and returns an absolute URL.

It takes one argument: the page that concludes the URL.

The argument defaults to index.php

*/

 

function absolute_url($page = 'index1.php')

{

//URL is http:// plus the host name of the current directory

 

$url = 'http://'.$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF']);

 

//REMOVE any trailling slashes

$url = rtrim($url, '/\\');

 

//add the page:

$url .= '/' .$page;

 

//return the url

 

return $url;

}

 

/*

* This function validates the form data (the email address and password).

* If both are present, the database is queried.

* The function requires a databaseconnection.

* The function returns an array of information, including:

* - a TRUE/FALSE variable indicating success

* - an array of either errors or the database result

*/

 

function check_login($dbc, $email = '', $pass = '')

{

$errors = array();

 

//validate the email and password

if (empty($email))

{

$errors[] = 'You forgot to enter your email address.';

}

 

else

{

$ea = mysqli_real_escape_string($dbc, trim($email));

}

 

if (empty($pass))

{

$errors[] = 'You forgot to enter your password.';

}

 

else

{

$p = mysqli_real_escape_string($dbc, trim($pass));

}

 

if(empty($errors))

{

$q = "SELECT user_id, first_name FROM usera WHERE email = '$ea' AND pass = '$p'";

$r = @mysqli_query($dbc, $q);

 

if(mysqli_num_rows($r) == 1)

{

$row = mysqli_fetch_array($r, MYSQLI_ASS0C);

 

return array(true, $row);

}

else

{

$errors[] = 'The email address and password entered do not match those on file.';

}

}

return array(false, $errors);

}

?>

Pls help.

Link to comment
Share on other sites

It's difficult to debug when the code is presented in this way. Please would you use code tags.

 

At first look, no error immediately jumps out. Which line is line 46? Look at that line and the few lines before it.

 

Probably not causing this error but it looks like you may have a typo on the tablename in the SELECT statement - users instead of usera?

  • Upvote 3
Link to comment
Share on other sites

By using code tags, the code is formatted differently to the rest of the comment. In the top right corner of the edit box is a little arrow icon, click on it to open the formatting icons available to you when posting a comment. The code tags icon looks like <> . Click on it and insert your code into the dialog box.

Link to comment
Share on other sites

Pls I will like to know what anyone here thinks about †ђξ use of PDO. Have been trying to wrap my head round it, bur it seems like am jst nt getting it.

I knw dis is not 'bout this book, bur I jst need to knw. Thanks fø̲̣̣я̅ understanding.

Link to comment
Share on other sites

Yes - worth the effort to learn how to use the PDO class. It takes an object oriented approach to connecting to most database systems - mysql, oracle, postgreSQL, SQLite. So if your project needs to change databases, you only need to change one line of code. I'm currently learning it myself  - Larry covers it in the 3rd edition of his book PHP Advanced and you can check out this tutorial.

Link to comment
Share on other sites

 Share

×
×
  • Create New...