RE: [PHP] Re: Login page
| From: | Angelo Zanetti | Date: | Thu, 06 May 2004 13:19:22 +0000 |
| Subject: | RE: [PHP] Re: Login page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185522@lists.php.net to get a copy of this message | ||
did you try comment out # login.php
like this:
//login.php
or what would you use login.php for?
angelo
-----Original Message-----
From: Erik Gjertsen [mailto:erik@gjertsen.as]
Sent: Thursday, May 06, 2004 2:54 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Login page
I forgot the error messages:
Warning: mysql_real_escape_string() expects parameter 2 to be resource, null
given in /home2/erik/gjertsen-www/Skole22/Loggin/login.php on line 28
Warning: mysql_real_escape_string() expects parameter 2 to be resource, null
given in /home2/erik/gjertsen-www/Skole22/Loggin/login.php on line 28
and 1.. is line 28 there error massages com.
thanks
Erik Gjertsen.
"Erik Gjertsen" <erik@gjertsen.as> wrote in message
news:20040506104258.85176.qmail@pb1.pair.com...
> I have made a login page but I got an error on line 1.....
>
> Can some one please help me to solve the problem
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "É÷c=
> äx–»£>e¶S$http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title>LoggInn</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
> />
> </head>
>
> <body>
> <?php
> # login.php
> if (isset($_POST['submit'])) { // Handel the form.
> require_once('../../../Connections/innlogging.php');
>
> mysql_select_db($database_innlogging, $innlogging);
> $query_logginn = "SELECT usrid, username, password1 FROM users";
> $logginn = mysql_query($query_logginn, $innlogging) or
die(mysql_error());
> $row_logginn = mysql_fetch_assoc($logginn);
> $totalRows_logginn = mysql_num_rows($logginn);
>
>
> // Crating a function for escaping the data.
> function escape_data ($data) {
> global $dbc; //meed the connection
> if (ini_get('magic_quotes_gpc')) {
> $data = stripslashes($data);
> }
> 1........ return mysql_real_escape_string($data, $dbc);
> } // end of function
>
> $message = NULL; // Create an enpty new variable
> // Check for a username
> if (empty($_POST['username'])) {
> $username = FALSE;
> $message .= '<p>You forgot to enter your username!</p>';
> } else {
> $username = escape_data($_POST['username']);
> }
> // Check for a Password
> if (empty($_POST['password1'])) {
> $password1 = FALSE;
> $message .= '<p>You forgot to enter your password!</p>';
> } else {
> $password1 = escape_data($_POST['password1']);
> }
> if ($username && $password1) { //if everything's ok.
> //Retrieve the user_id an name for that username and password
combination.
> $query = "SELECT usrid name FROM users WHERE username='$username' AND
> password1=PASSWORD('$password1')";
> $result = @mysql_query ($query); //Run the query
> $row = mysql_fetch_array ($result, MYSQL_NUM); //Return a record, if
> applicable.
> if ($row) { //A record was pulled from the database.
> //Set the cookies & redirect.
> setcookie ('name', $row[1]);
> setcookie ('usrid', $row[1]);
> header ("Location: http://" .
> $_SERVER['HTTP_HOST'] .
> dirname($_SERVER['PHP_SELF']) . "/Loggedin.php");
> exit(); //Quit the script
> } else { // No record matched the query.
> $message = '<p>The username and password entered do not match on
> file.</p>';
> }
> mysql_close(); // Close the databaseconection.
> } else {
> $message = '<p>Please try again.</p>';
> }
> } // End of themail submitconditional.
>
> //Print the error message if ther is one
> if (isset($message)) {
> echo '<font color="red">', $message, '</font>';
> }
>
> ?>
>
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>"
> method="post">
> <fieldset><legend>Enter your information in the form below:</legend>
> <p><b>User Name:</b> <input type="text"
> name="username" size="10"
> maxlength="20" value="<?php if
> (isset($_POST['username'])) echo $_POST['username']; ?>"
> /></p>
>
> <p><b>Password:</b> <input type="password1"
> name="password1" size="20"
> maxlength="20" /></p>
> <div align="center"><input type="submit" name="submit"
> value="Login"
> /></div>
> </fieldset>
> </form>
> </body>
> </html>
>
>
> Thanks
> Erik Gjertsen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911