Jump to content

need help with login script

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
lordwittie

lordwittie

    Newbie

  • Members
  • PipPip
  • 17 posts
hi,

I need help with this login script:
<?
//***************************************
// This is downloaded from www.plus2net.com //
/// You can distribute this code with the link to www.plus2net.com ///
//  Please don't  remove the link to www.plus2net.com ///
// This is for your learning only not for commercial use. ///////
//The author is not responsible for any type of loss or problem or damage on using this script.//
/// You can use it at your own risk. /////
//*****************************************

$mysql_host = "mysql15.000webhost.com";
$mysql_database = "a7636106_signups";
$mysql_user = "a7636106_LW";
$mysql_password = "lo87tg";


////////////////////////////////////////
////// DONOT EDIT BELOW  /////////
///////////////////////////////////////
$user="a7636106_LW";
$password="******";
$database="a7636106_signups";
$hostname="mysql15.000webhost.com";
$link=mysql_connect($hostname,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$mysql_database",$link) or die ("could not open db".mysql_error());
//////////////////////////////
?>
<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>Signup</title>
</head>

<body>
<?

$userid=$_POST['userid'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$agree=$_POST['agree'];
$todo=$_POST['todo'];
$email=$_POST['email'];
$name=$_POST['name'];
$sex=$_POST['sex'];



if(isset($todo) and $todo=="post"){

$status = "OK";
$msg="";

// if userid is less than 3 char then status is not ok
if(!isset($userid) or strlen($userid) <3){
$msg=$msg."User id should be =3 or more than 3 char length<BR>";
$status= "NOTOK";}                    

if(mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){
$msg=$msg."Userid already exists. Please try another one<BR>";
$status= "NOTOK";}                    


if ( strlen($password) < 3 ){
$msg=$msg."Password must be more than 3 char legth<BR>";
$status= "NOTOK";}                    

if ( $password <> $password2 ){
$msg=$msg."Both passwords are not matching<BR>";
$status= "NOTOK";}                    


if ($agree<>"yes") {
$msg=$msg."You must agree to terms and conditions<BR>";
$status= "NOTOK";}    

if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
}else{
if(mysql_query("insert into plus_signup(userid,password,email,name,sex) values('$userid','$password','$email','$name','$sex')")){
echo "<font face='Verdana' size='2' color=green>Welcome, You have successfully signed up</font>";}
else{ echo "Database Problem, please contact Site admin";
//echo mysql_error();
}

}
}
?>
<center>
<br><br><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center> 

</body>

</html>
the information is all correct, but it gives this error:

Quote

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a7636106/public_html/signupck.php on line 62

Database Problem, please contact Site admin
this is line 60:
if(mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){

Edited by James.H, 28 March 2010 - 04:49 AM.


#2
Arctic Fire

Arctic Fire

    Learning Programmer

  • Members
  • PipPipPip
  • 48 posts
Just put this on a line by itself and see if it returns an error.

mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'") or die(mysql_error());


#3
lordwittie

lordwittie

    Newbie

  • Members
  • PipPip
  • 17 posts
yes, same error as before...

#4
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
I notice you are using $userid, but your variable is $user.. could this have something to do with it?
Checkout my new forum! http://adminreference.com/