Jump to content

Php - mysql doesn't match?


zero_ZX

Recommended Posts

Hi all, so i want to use whmcs and smf to make a post-to-host forum, however this is not standard for any of the two scripts, so i tried to find a way, and got to "credits". This is just a small script, which transfer credits from smf to whmcs. However as i'm new to php i'm not sure this is correct. Please tell me :D

I've only coded the first small part which ckecks if the id and password matches, and then if it doesn't the script should die.

<p>Transfer resaults:</p>
<?php

//connect to base1 server
$con = mysql_connect("localhost","MYSQL USER","MYSQL PASS");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
//select the smf database
mysql_select_db("MYSQL DB", $con);

// Let's validate all the fields

//validating credit password
$query = "SELECT member_id FROM smf_themes WHERE member_id = '{$_POST['memberid']}' and credits = '{$_POST['creditpass']}'"; //or die(mysql_error());

$result = mysql_query($query,$con);

if(mysql_num_rows($result) != 1); //if member id and creditpass didn't match do:
{
echo  "An error occoured: <br /> Your member id and/or creditpassword didn't math. Please try again";

die();

}

//Let's see if the user tries to cheat by inserting other stuff into the transfer amount other than positive numbers.


//Let's see if the user tries to cheat by transfering more credits than he got


//Make sure whmcs email exists


//DONE!! Start the transfer!

?>
[code]

Link to comment
Share on other sites

try this code:

<p>Transfer resaults:</p>
<?php

//connect to base1 server
$con = mysql_connect("localhost","MYSQL USER","MYSQL PASS");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
//select the smf database
mysql_select_db("MYSQL DB", $con);

// Let's validate all the fields

//validating credit password
$select = "SELECT member_id FROM smf_themes WHERE member_id = '{$_POST['memberid']}' and credits = '{$_POST['creditpass']}'";
$result = mysql_query($select, $con); 
$row = mysql_fetch_array($result);

if(mysql_num_rows($result) != 1); //if member id and creditpass didn't match do:
{
echo  "An error occoured: <br /> Your member id and/or creditpassword didn't math. Please try again";

die();

}

//Let's see if the user tries to cheat by inserting other stuff into the transfer amount other than positive numbers.


//Let's see if the user tries to cheat by transfering more credits than he got


//Make sure whmcs email exists


//DONE!! Start the transfer!

?>
[code]

Link to comment
Share on other sites

Thanks a lot :D

So, i coded the next part:

//Let's see if the user tries to cheat by transferring more credits than he got.
	//Get users total points

$select = "SELECT points FROM smf_members WHERE id_member = '{$_POST['memberid']}' and credits = '{$_POST['creditpass']}'";
$result = mysql_query($select, $con); 
$row = mysql_fetch_array($result);

if ("'{$_POST['creditsamount']}' > (mysql_num_rows($result)")
{
echo  "An error occoured: <br /> Are you trying to cheat? You do not have enough points to do this!";

die();

}

But as told, i'm still not sure.. I want to read how much points/credits the user actually got, then if the number they enter in the form is bigger than that, it will die. Mostly of it is just copy paste from the previous step.

 

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.