Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 454 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need help php code (My final project in college)

#1
login ceking.
PHP Code:
<?php
include "../config/koneksi.php";
$pass=md5($_POST[password]);

$login=mysql_query("SELECT * FROM user WHERE id_user='$_POST[username]' AND password='$pass'");
$ketemu=mysql_num_rows($login);
$r=mysql_fetch_array($login);

// Apabila username dan password ditemukan
if ($ketemu 0){
  
session_start();
  
session_register("namauser");
  
session_register("passuser");
  
session_register("namalengkap");

  
$_SESSION[namauser]=$r[id_user];
  
$_SESSION[passuser]=$r[password];
  
$_SESSION[namalengkap]=$r[nama];
  
header('location:media.php?module=home');
}
else{
  echo 
"<link href=../config/adminstyle.css rel=stylesheet type=text/css>";
  echo 
"<center>Login gagal! username & password tidak benar<br>";
  echo 
"<a href=index.php><b>ULANGI LAGI</b></a></center>";
}
?>


if i run in program the message is
Quote:Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\travel\admin\cek_login.php on line 5

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\travel\admin\cek_login.php on line 6

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\travel\admin\cek_login.php on line 7
please check, is there anything wrong?
thank's alot.
sorry if my language is less understood
Reply

#2
You're sending a query to the database, but have you connected to the database in the first place?
For example using the

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

Reply

#3
I think it's my first connect the database.
I use this configuration
PHP Code:
<?
$server 
"localhost";
$username "root";
$password "";
$database "mitra";

// Koneksi dan memilih database di server
mysql_connect($server,$username,$password) or die("Koneksi gagal");
mysql_select_db($database) or die("Database tidak bisa dibuka");
?>

if still there is something wrong?
Reply

#4
You use header(location), this doesnt work in all versions of internet explorer. you should rather echo "<meta http-equiv="refresh" content="0;url=' . sprintf("yourpage.php") . '" />";
Reply

#5
Quote:(05-06-2011, 03:22 PM)ghoza Wrote:

[To see links please register here]

I think it's my first connect the database.
I use this configuration
PHP Code:
<?
$server 
"localhost";
$username "root";
$password "";
$database "mitra";

// Koneksi dan memilih database di server
mysql_connect($server,$username,$password) or die("Koneksi gagal");
mysql_select_db($database) or die("Database tidak bisa dibuka");
?>

if still there is something wrong?
You need to assign the connect function to a variable which your code is set up to be $database.

so
PHP Code:
// Koneksi dan memilih database di server
mysql_connect($server,$username,$password) or die("Koneksi gagal"); 
should be
PHP Code:
// Koneksi dan memilih database di server
$database mysql_connect($server,$username,$password) or die("Koneksi gagal"); 

Edit: Also, header("Location: "); is a syntactically correct

[To see links please register here]

301 redirect call. I believe IE has supported HTTP 1.0 fully since IE 3, however, not all browsers will recognize a meta or javascript redirect.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through