PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jul 07, 2020 1:24 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Problems with code
PostPosted: Fri Feb 10, 2006 11:44 pm 
Offline
Forum Commoner

Joined: Wed Oct 12, 2005 5:21 am
Posts: 33
this code works pefectly fine on my localhost but when i upload it every thing seems to go wrong. It seems to have a lot of problems with this line of code "mysql_fetch_array ($result, MYSQL_NUM);". Can any one help?
And i have changed the database details.

Syntax: [ Download ] [ Hide ]
<?php

session_start();

?>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Admin Login</title>

<link rel="stylesheet" type="text/css" href="style.css" media="all" title="StyleSheet"/>

</head>

<body>

<table width="400" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#999999">

  <tr>

    <td><table width="400" border="1" align="center" cellpadding="0" cellspacing="0">

      <tr>

        <td><div align="center"><img src="images/banner.jpg"></div></td>

      </tr>

      <tr>

        <td height="145">

                  <br><p align="center">

<?

if($_POST['submit']){

require_once('mysql_connect.php');

$username = $_POST['username'];

$password = md5($_POST['password']);

$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";

$result = @mysql_query ($query);

$row = mysql_fetch_array ($result, MYSQL_NUM);

if ($row) {    

                session_register("username");

                session_register("user_id");

                $_SESSION['username'] = $row[1];

                $_SESSION['user_id'] = $row[0];

               

                echo "<font face=\"verdana\" size=\"1\" color=\"#000000\">Login Complete<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=menu.php\"></font>";

        } else {

        echo "<font face=\"verdana\" size=\"1\" color=\"#000000\">Login Failed<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=index.php\"></font>";

        }

} ?>

                  </p>

                  <br><form name="form1" method="post" action="index.php">

          <div align="center"><span class="style1">Username:</span><br>

                <input name="username" type="text" class="style1" id="username">

                <br>

                <span class="style1">Password:</span> <br>

            <input name="password" type="password" class="style1" id="password">

            <br>

            <br>

            <input name="submit" type="submit" class="style1" id="submit" value="Login">

            <br>

            <br>

          </div>

                </form></td>

      </tr>

          <tr>

          <td align="center"><?php include('copyright.php'); ?></td>

          </tr>

    </table></td>

  </tr>

</table>

</body>

</html>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 12:01 am 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
First of all, you need to use a function like on your post data before putting it into a query


Second of all take the @ off the @mysql_query ($query);


Thirdly, add
Syntax: [ Download ] [ Hide ]
or die(mysql_error())
to the end of the query, post any error messages you are getting


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 12:51 am 
Offline
Forum Commoner

Joined: Wed Oct 12, 2005 5:21 am
Posts: 33


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 1:17 am 
Offline
Forum Regular
User avatar

Joined: Sun Aug 14, 2005 12:02 am
Posts: 764
Location: Long Island, New York


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 2:02 am 
Offline
Forum Commoner

Joined: Wed Oct 12, 2005 5:21 am
Posts: 33
Syntax: [ Download ] [ Hide ]
$result = mysql_query ($query);

$row = mysql_fetch_array ($result, MYSQL_NUM);


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 2:26 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 7:13 am 
Offline
Site Administrator
User avatar

Joined: Sun May 19, 2002 10:24 pm
Posts: 6887

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group