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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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");
} 
} 

?> 

Link to comment
Share on other sites

$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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.