Unwanted message error when login with mysql

Codes here !

Moderators: macek, egami, gesf

youpi
New php-forum User
New php-forum User
Posts: 9
Joined: Tue Jan 28, 2003 10:20 am

Unwanted message error when login with mysql

Postby youpi » Tue Jan 28, 2003 10:31 am

hi,

when i try to log with a wrong account to mysql account, i get warning displayed. I would like to bypass these messages but also be able to know if something went wrong.

thanks

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Tue Jan 28, 2003 3:16 pm

You mean when login to Mysql server or when you login with data kept in a database through a php script?

youpi
New php-forum User
New php-forum User
Posts: 9
Joined: Tue Jan 28, 2003 10:20 am

Postby youpi » Wed Jan 29, 2003 3:47 am

hi,

i get this message when i am trying to get access to mysql server through a php script. I think it would be better if the user if he gives a wrong account doesn't get these warnings in his browser.

hope my english is good enough to be understood :D

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Wed Jan 29, 2003 4:25 pm

ok, I've got a script that could help:

Code: Select all

if(isset($HTTP_POST_VARS["submit"])){//this var comes from the login form, the button should be named "submit"
$server="localhost";
$login="my_login";
$pass="xxxxxxx";
$database="jmontcer";
$table="foro_users";

$user = $HTTP_POST_VARS["user"];
$passwrd = $HTTP_POST_VARS["pass"];

$conection=mysql_connect($server,$login,$pass) or die("<h3>Couldn't connect to the database server</h3></BODY></HTML>");     
mysql_select_db($database,$conection)or die ("<h3>Couldn't select database</h3></BODY></HTML>");
$sql = "SELECT user_id, username, user_password FROM ".$table." where username='$user' and user_password='$passwrd'";
$sql_result= mysql_query($sql,$conection) or die ("<h3>Couldn't select iformation</h3></BODY></HTML>");
if ($row = mysql_fetch_array($sql_result)){
   do{
      anything_you_want($row["user_id"],$row["username"]);
   }while   ($row = mysql_fetch_array($sql_result));
}else{
   echo "No coincidences were found, try again please.";
}
mysql_close($conection);


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest