Jump to content

can someone please help? php script inside


koopz

Recommended Posts

I was just wondering if these scripts were right?

 

LOGIN SCRIPT

<?php 
mysql_connect("localhost","username","password") or die(); 
mysql_select_db("koopz_orthlint") or die();

$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die();

$check2 = mysql_num_rows($check);
if ($check2 == 0) {
print "words=User doesn't exist.&checklog=3";
die();
}
while($info = mysql_fetch_array( $check )) 
{

if ($_POST['pass'] != $info['password']) {
print "words=Incorrect Password.&checklog=4";
die();
}else 
{ 
print "words=You are logged in.&checklog=5";
die();
} 
} 


?> 

 

REGISTER SCRIPT

<?php 
mysql_connect("localhost","username","password") or die(); 
mysql_select_db("koopz_orthlint") or die(); 

$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") 
or die();

$check2 = mysql_num_rows($check);
if ($check2 != 0) {
print "words=Username already exists.&checklog=1";
die();
}

$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
$add_member = mysql_query($insert);
print "words=You are registered.&checklog=2";
die();
?>

 

any help would be appreciated

 

theres is no errors i think. (php isnt on my comp but im learning basics) and i was trying to make a login system with flash

http://koopz.quotaless.com/66.swf thats all i get. it has worked before just i changed some stuff to get bugs out and now it wont work.

I'm sorry I have no idea when it comes to using flash as I've never used it - maybe someone else can help?

 

If you want to learn PHP on your computer you can download WAMP and install that. It'll turn your computer into a local server where you can test PHP scripts without having to uploaded them to a remote server.

heres the whole code

<?php 

mysql_connect("localhost","username","password") or die("error1"); 
mysql_select_db("dbname") or die("error2");

$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die("error3");

$check2 = mysql_num_rows($check) or die("error4");
if ($check2 == 0) {
print "words=User doesn't exist.&checklog=3";
die("error5");
}
while($info = mysql_fetch_array( $check ) or die("error6")) 
{

if ($_POST['pass'] != $info['password']) {
print "words=Incorrect Password.&checklog=4";
die("error7");
}else 
{ 
print "words=You are logged in.&checklog=5";
die("error8");
} 
} 

?> 

$check is a RESOURCE not a query string (which is what the num_rows function requires)

 

Sorry Andy, but (as I'm sure your aware) mysql_num_rows() expects a resource.

 

I see nothing wrong with the above code (besides poor formatting). What are you expecting and what are you actually getting?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.