zero_ZX Posted June 23, 2009 Share Posted June 23, 2009 Hi, So, i have my script, which is supposed to transfer points from one place to another. <p>Transfer resaults:</p> <?php //connect to base1 server $con = mysql_connect("localhost","usr","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } //select the smf database mysql_select_db("db", $con); // Let's validate all the fields //validating credit password $select = "SELECT member_id FROM smf_themes WHERE idmember_ = '{$_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 occured: <br /> Your member id and/or creditpassword didn't match. 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. //This has been done by limiting the allowed characters in the form to 2 (two) //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 occured: <br /> Are you trying to cheat? You do not have enough points to do this!"; die(); } //Make sure whmcs email exists //select whmcs db mysql_select_db("db", $con); //now let's get on with the email $select = "SELECT email FROM tblcients WHERE email = '{$_POST['whmcsemail']}'"; $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 occured: <br /> The entered email does not exists. Have you registered?"; die(); } //Is the member banned from using points? //select the db mysql_select_db("db", $con); //go back and check $select = "SELECT credits2 FROM smf_themes WHERE id_member = '{$_POST['memberid']}'"; $result = mysql_query($select, $con); $row = mysql_fetch_array($result); if(mysql_num_rows($result) != Active); //if member is not an active user of credits do: { echo "An error occured: <br /> You are currently banned/suspended from the credit service. Contact MT if this is a mistake."; die(); } //DONE!! Start the transfer! // Remove the credits from smf first $insert = "INSERT INTO points FROM smf_members WHERE id_member = '{$_POST['memberid']}'" VALUES (-'{$_POST['creditsamount']}'); //Select whmcs database mysql_select_db("db", $con); // Insert the credits to whmcs help?????? ?> Now at first, i don't even know if this code is correct lol, any ways i need some help with the last part. After the user's data has been approved, i want the script to search in the db, table tblclients and find the submitted email, and then get the id When it has the id i need something like $insert = INSERT INTO tblcredit (clientid, date, description, amount) VALUES (THE ID I NEED HELP TO GET, $date, Automatic insert by point system, '{$_POST['creditsamount']}') Link to comment https://forums.phpfreaks.com/topic/163422-get-data-and-use-it-later-on/ Share on other sites More sharing options...
zero_ZX Posted June 24, 2009 Author Share Posted June 24, 2009 Up Link to comment https://forums.phpfreaks.com/topic/163422-get-data-and-use-it-later-on/#findComment-862491 Share on other sites More sharing options...
ninedoors Posted June 24, 2009 Share Posted June 24, 2009 First of all, are you using SMF software? Are you trying to create a custom function or page? If so I should be able to help you if you tell me what you are trying to do. Right now your code isn't close to what you need to have to pull data from your smf database though their system. I am assuming you are using 2.0 RC1-1? Link to comment https://forums.phpfreaks.com/topic/163422-get-data-and-use-it-later-on/#findComment-862554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.