Jump to content

Recommended Posts

 


<?php

include 'config.php';
include 'opendb.php';



function generatePassword ($length = 13)
{

  // start with a blank password
  $password = "";

  // define possible characters
  $possible = "0123456789bcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
    
  // set up a counter
  $i = 0; 
    
  // add random characters to $password until $length is reached
  while ($i < $length) { 

    // pick a random character from the possible ones
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
        
    // we don't want this character if it's already in the password
    if (!strstr($password, $char)) { 
      $password .= $char;
      $i++;
    }

  }

  // done!
  return $password;

}

//connect to database
$con = mysql_connect("localhost","root","");


//if mysql doesnt exist
if (!$con){
  die('Could not connect: ' . mysql_error());
}


//select database
mysql_select_db("my_db", $con);




// Create table in my_db database
$sql = "CREATE TABLE gamecard
(

Serialnum varchar(13),
Activatecode varchar(13),
Ownerid varchar(13), 
Status varchar(13),
Downleft varchar(13),
Downright varchar(13),
Upline varchar(13),
Expireddate varchar(13),
Createdate varchar(13),
Point varchar(13)


)";
mysql_query($sql,$con);


$result = mysql_query("SELECT * FROM gamecard") or die('Query failed: ' . mysql_error());

while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
	$serial=$row["Serialnum"];
	echo "serial=".$serial;
};
$serial++;







$cardnum=$_POST['cardnum'];
$count=0;




while ($count<$cardnum) {

$randompass=generatePassword();




//insert into table
$sql="INSERT INTO gamecard (Serialnum,Activatecode)
VALUES
('$serial','$randompass')";


//insert into table (action)
mysql_query($sql,$con);



//if (!mysql_query($sql,$con))
//  {
// die('Error: ' . mysql_error());
// }

//display successful message
echo "card successful registered!, 1 record added";
$count++;
$serial++;


}//end of while loop


//display database record
//$result = mysql_query("SELECT * FROM gamecard");

//while($row = mysql_fetch_array($result))
//  {
//  echo $row['serialnum'] ;
// echo "<br />";
//  }




?>







 

 

 

<?php
session_start();

if(isset($_POST["ic"]))
{
$_SESSION["ic"] = $_POST["ic"];
}
if(isset($_POST["fullname"]))
{
$_SESSION["fullname"] = $_POST["fullname"];
}

if(isset($_POST["gender"]))
{
$_SESSION["gender"] = $_POST["gender"];
}

if(isset($_POST["dob"]))
{
$_SESSION["dob"] = $_POST["dob"];
}


if(isset($_POST["address"]))
{
$_SESSION["address"] = $_POST["address"];
}

if(isset($_POST["postcode"]))
{
$_SESSION["postcode"] = $_POST["postcode"];
}

if(isset($_POST["city"]))
{
$_SESSION["city"] = $_POST["city"];
}

if(isset($_POST["state"]))
{
$_SESSION["state"] = $_POST["state"];
}

if(isset($_POST["phonenumber"]))
{
$_SESSION["phonenumber"] = $_POST["phonenumber"];
}

if(isset($_POST["hpnumber"]))
{
$_SESSION["hpnumber"] = $_POST["hpnumber"];
}

if(isset($_POST["banktype"]))
{
$_SESSION["banktype"] = $_POST["banktype"];
}
if(isset($_POST["accname"]))
{
$_SESSION["accname"] = $_POST["accname"];
}

if(isset($_POST["accnumber"]))
{
$_SESSION["accnumber"] = $_POST["accnumber"];
}



//$_SESSION["gender"] = $_POST["gender"];
//$_SESSION["address"] = $_POST["address"];
//$_SESSION["postcode"] = $_POST["postcode"];
//$_SESSION["city"] = $_POST["city"];
//$_SESSION["state"] = $_POST["state"];
//$_SESSION["phonenumber"] = $_POST["phonenumber"];
//$_SESSION["hpnumber"] = $_POST["hpnumber"];
//$_SESSION["banktype"] = $_POST["banktype"];
//$_SESSION["accname"] = $_POST["accname"];
//$_SESSION["accnumber"] = $_POST["accnumber"];


//store data into  variable

echo "<br>";
echo "Username = ";
echo $_SESSION["username"];
echo "<br>";
echo "Password = ";
echo $_SESSION["password"];
echo "<br>";
echo "Country = ";
echo $_SESSION["country"];
echo "<br>";
echo "IC = ";
echo $_SESSION["ic"];
echo "<br>";
echo "Fullname = ";
echo $_SESSION["fullname"];
echo "<br>";
echo "Gender = ";
echo $_SESSION["gender"];
echo "<br>";
echo "DOB = ";
echo $_SESSION["dob"];
echo "<br>";
echo "Address = ";
echo $_SESSION["address"];
echo "<br>";
echo " Postcode= ";
echo $_SESSION["postcode"];
echo "<br>";
echo "City = ";
echo $_SESSION["city"];
echo "<br>";
echo "State = ";
echo $_SESSION["state"];
echo "<br>";
echo "Phone Number = ";
echo $_SESSION["phonenumber"];
echo "<br>";
echo "HP Number = ";
echo $_SESSION["hpnumber"];
echo "<br>";
echo "BankYype = ";
echo $_SESSION["banktype"];
echo "<br>";
echo "Account Name = ";
echo $_SESSION["accname"];
echo "<br>";
echo "Account Number = ";
echo $_SESSION["accnumber"];
echo "<br>";
echo "Card ID= ";
echo $_SESSION["cardID"];
echo "<br>";
echo "Upline ID= ";
echo $_SESSION["uplineID"];






if(isset($_REQUEST['button']))
{
  
echo "<BR/>"."Thank you for your registration";

$con = mysql_connect("localhost","root","");
mysql_select_db("my_db", $con);

$sql = "CREATE TABLE person
(


	Username varchar(13),
	Password varchar(13),
	Country varchar(10),
	IC       varchar(13),
	FullName varchar(40),
	Gender varchar(15),
	DOB varchar(15),
	Address varchar(80),
	Postcode varchar(10),
	City varchar(20),
	State varchar(20),
	PhoneNumber varchar(15),
	HpNumber varchar(15),
	BankType varchar(30),
	AccName varchar(40),
	AccNumber varchar(15)
)";
mysql_query($sql,$con);

//insert into table
$sql="INSERT INTO person (Username,Password,Country,IC,FullName,Gender,DOB,Address,Postcode,City,State,PhoneNumber,HpNumber,BankType,AccName,AccNumber)
VALUES ('$_SESSION[username]','$_SESSION[password]','$_SESSION[country]',
         '$_SESSION[ic]','$_SESSION[fullname]','$_SESSION[gender]','$_SESSION[dob]',
	 '$_SESSION[address]','$_SESSION[postcode]','$_SESSION[city]','$_SESSION[state]',
	 '$_SESSION[phonenumber]','$_SESSION[hpnumber]','$_SESSION[banktype]',
	 '$_SESSION[accname]','$_SESSION[accnumber]')";


mysql_query($sql,$con);

echo "</br>";

echo "<a href=\"main.php\">back to main </a>";

//begin checking card id

$result = mysql_query("SELECT * FROM gamecard where Serialnum=$_SESSION[cardID]") or die('Query failed: ' . mysql_error());


$numrows=mysql_num_rows($results);

// If we have no results, offer a google search as an alternative

if ($numrows == 0)
  {

  echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
  }



}//end of isset


?>


<html>
<body>

<form name='noname' action='register3.php' method=post>
<input type="submit" name='button' value='comfirm'>
</form>

</body>
</html>


when i typed in wrong cardID in the form...error =

back to main Query failed: Unknown column 'testing999' in 'where clause'

 

when i typed the correct(which is '2') cardID in the form error=

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\register3.php on line 195

 

Sorry, your search: "" returned zero results

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/65814-solved-mysql-problem/
Share on other sites

first php file

// Create table in my_db database
$sql = "CREATE TABLE gamecard
(

Serialnum varchar(13),
Activatecode varchar(13),
Ownerid varchar(13), 
Status varchar(13),
Downleft varchar(13),
Downright varchar(13),
Upline varchar(13),
Expireddate varchar(13),
Createdate varchar(13),
Point varchar(13)


)";
mysql_query($sql,$con);


$result = mysql_query("SELECT * FROM gamecard") or die('Query failed: ' . mysql_error());

while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
	$serial=$row["Serialnum"];
	echo "serial=".$serial;
};
$serial++;







$cardnum=$_POST['cardnum'];
$count=0;




while ($count<$cardnum) {

$randompass=generatePassword();




//insert into table
$sql="INSERT INTO gamecard (Serialnum,Activatecode)
VALUES
('$serial','$randompass')";


//insert into table (action)
mysql_query($sql,$con);



//if (!mysql_query($sql,$con))
//  {
// die('Error: ' . mysql_error());
// }

//display successful message
echo "card successful registered!, 1 record added";
$count++;
$serial++;


}//end of while loop

 

another file file

 





//begin checking card id

$result = mysql_query("SELECT * FROM gamecard where Serialnum=$_SESSION[cardID]") or die('Query failed: ' . mysql_error());


$numrows=mysql_num_rows($results);

// If we have no results, offer a google search as an alternative

if ($numrows == 0)
  {

  echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
  }



}//end of isset

 

 

thanks..

Link to comment
https://forums.phpfreaks.com/topic/65814-solved-mysql-problem/#findComment-328927
Share on other sites

i added bellowing code but it cant update Ownerid, the $cardID,$_SESSION[ic] all correct.

if ($numrows == 0)
  {
  	echo "testing3";

  echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
  
  }
  else{
  	echo "testing4";
  	echo "cardID=".$cardID;
  	 while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
	$serial=$row["Serialnum"];
	echo "serial=".$serial;
	echo "ic=".$_SESSION[ic];
  	 }
  	   	echo "testing5";
     
  	
  	   mysql_query("UPDATE gamecard SET Ownerid = $_SESSION[ic] 
                    where Serialnum =$cardID"); 
  	  	echo "testing6";
  
  }

 

 

Link to comment
https://forums.phpfreaks.com/topic/65814-solved-mysql-problem/#findComment-329490
Share on other sites

<?php
session_start();

if(isset($_POST["ic"]))
{
$_SESSION["ic"] = $_POST["ic"];
}
if(isset($_POST["fullname"]))
{
$_SESSION["fullname"] = $_POST["fullname"];
}

if(isset($_POST["gender"]))
{
$_SESSION["gender"] = $_POST["gender"];
}

if(isset($_POST["dob"]))
{
$_SESSION["dob"] = $_POST["dob"];
}


if(isset($_POST["address"]))
{
$_SESSION["address"] = $_POST["address"];
}

if(isset($_POST["postcode"]))
{
$_SESSION["postcode"] = $_POST["postcode"];
}

if(isset($_POST["city"]))
{
$_SESSION["city"] = $_POST["city"];
}

if(isset($_POST["state"]))
{
$_SESSION["state"] = $_POST["state"];
}

if(isset($_POST["phonenumber"]))
{
$_SESSION["phonenumber"] = $_POST["phonenumber"];
}

if(isset($_POST["hpnumber"]))
{
$_SESSION["hpnumber"] = $_POST["hpnumber"];
}

if(isset($_POST["banktype"]))
{
$_SESSION["banktype"] = $_POST["banktype"];
}
if(isset($_POST["accname"]))
{
$_SESSION["accname"] = $_POST["accname"];
}

if(isset($_POST["accnumber"]))
{
$_SESSION["accnumber"] = $_POST["accnumber"];
}



//$_SESSION["gender"] = $_POST["gender"];
//$_SESSION["address"] = $_POST["address"];
//$_SESSION["postcode"] = $_POST["postcode"];
//$_SESSION["city"] = $_POST["city"];
//$_SESSION["state"] = $_POST["state"];
//$_SESSION["phonenumber"] = $_POST["phonenumber"];
//$_SESSION["hpnumber"] = $_POST["hpnumber"];
//$_SESSION["banktype"] = $_POST["banktype"];
//$_SESSION["accname"] = $_POST["accname"];
//$_SESSION["accnumber"] = $_POST["accnumber"];


//store data into  variable

echo "<br>";
echo "Username = ";
echo $_SESSION["username"];
echo "<br>";
echo "Password = ";
echo $_SESSION["password"];
echo "<br>";
echo "Country = ";
echo $_SESSION["country"];
echo "<br>";
echo "IC = ";
echo $_SESSION["ic"];
echo "<br>";
echo "Fullname = ";
echo $_SESSION["fullname"];
echo "<br>";
echo "Gender = ";
echo $_SESSION["gender"];
echo "<br>";
echo "DOB = ";
echo $_SESSION["dob"];
echo "<br>";
echo "Address = ";
echo $_SESSION["address"];
echo "<br>";
echo " Postcode= ";
echo $_SESSION["postcode"];
echo "<br>";
echo "City = ";
echo $_SESSION["city"];
echo "<br>";
echo "State = ";
echo $_SESSION["state"];
echo "<br>";
echo "Phone Number = ";
echo $_SESSION["phonenumber"];
echo "<br>";
echo "HP Number = ";
echo $_SESSION["hpnumber"];
echo "<br>";
echo "BankYype = ";
echo $_SESSION["banktype"];
echo "<br>";
echo "Account Name = ";
echo $_SESSION["accname"];
echo "<br>";
echo "Account Number = ";
echo $_SESSION["accnumber"];
echo "<br>";
echo "Card ID= ";
echo $_SESSION["cardID"];
echo "<br>";
echo "Upline ID= ";
echo $_SESSION["uplineID"];






if(isset($_REQUEST['button']))
{
  
echo "<BR/>"."Thank you for your registration";

$con = mysql_connect("localhost","root","");
mysql_select_db("my_db", $con);

$sql = "CREATE TABLE person
(


	Username varchar(13),
	Password varchar(13),
	Country varchar(10),
	IC       varchar(13),
	FullName varchar(40),
	Gender varchar(15),
	DOB varchar(15),
	Address varchar(80),
	Postcode varchar(10),
	City varchar(20),
	State varchar(20),
	PhoneNumber varchar(15),
	HpNumber varchar(15),
	BankType varchar(30),
	AccName varchar(40),
	AccNumber varchar(15)
)";
mysql_query($sql,$con);

//insert into table
$sql="INSERT INTO person (Username,Password,Country,IC,FullName,Gender,DOB,Address,Postcode,City,State,PhoneNumber,HpNumber,BankType,AccName,AccNumber)
VALUES ('$_SESSION[username]','$_SESSION[password]','$_SESSION[country]',
         '$_SESSION[ic]','$_SESSION[fullname]','$_SESSION[gender]','$_SESSION[dob]',
	 '$_SESSION[address]','$_SESSION[postcode]','$_SESSION[city]','$_SESSION[state]',
	 '$_SESSION[phonenumber]','$_SESSION[hpnumber]','$_SESSION[banktype]',
	 '$_SESSION[accname]','$_SESSION[accnumber]')";


mysql_query($sql,$con);

echo "</br>";

echo "<a href=\"main.php\">back to main </a>";

//begin checking card id
$cardID=$_SESSION['cardID'];

$result = mysql_query("SELECT * FROM gamecard where Serialnum='$cardID'") or die('Query failed: ' . mysql_error());



$numrows=mysql_num_rows($result);

// If we have no results, offer a google search as an alternative

if ($numrows == 0)
  {
  	echo "testing3";

  echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
  
  }
  else{
  	echo "testing4";
  	echo "cardID=".$cardID;
  	 while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
	$serial=$row["Serialnum"];
	echo "serial=".$serial;
	echo "ic=".$_SESSION[ic];
  	 }
  	   	echo "testing5";
     
  	
  	   mysql_query("UPDATE gamecard SET Ownerid = $_SESSION[ic] 
                    where Serialnum ='$cardID'"); 
  	  	echo "testing6";
  
  }



}//end of isset


?>


<html>
<body>

<form name='noname' action='register3.php' method=post>
<input type="submit" name='button' value='comfirm'>
</form>

</body>
</html>

 

the lastest code, i modify already, still the same..weird ???

Link to comment
https://forums.phpfreaks.com/topic/65814-solved-mysql-problem/#findComment-329567
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.