dean7 Posted September 14, 2010 Share Posted September 14, 2010 Hi all, Ive latly coded a option for my website which allowes users to send money. Ive finished coding it but when I press the submit button the money dont get sent to the other user it just puts it in the url bar. Example: http://********.com/newbank.php?touser=Test&sendmoney=1000000000&sendmoney=Send+Money! <?php session_start(); include ("includes/db_connect.php"); include ("includes/functions.php"); logincheck(); $username = $_SESSION['username']; // Fetch users stuff.. $fetch_u = mysql_query("SELECT * FROM users WHERE username='$username'") or die (mysql_error()); $fetch_users = mysql_fetch_object($fetch_u); // Fetch bank stuff.. $fetch_b = mysql_query("SELECT * FROM bank") or die (mysql_error()); $fetch_bank = mysql_fetch_object($fetch_b); // User sending money.. if ($_POST['sendmoney']){ $send_money = strip_tags($_POST['ammount']); $to_user = strip_tags($_POST['touser']); if (!$to_user){ echo ("You must enter a username."); }elseif ($to_user){ $user_real = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username = '$to_user'")) or die (mysql_error()); if ($user_real == 0){ echo ("No such user!"); }elseif ($user_real != 0){ if ($send_money > "0"){ if ($send_money == 0 || !$send_money || ereg('[^0-9]',$send_money)){ echo ("You carnt send that type of money"); }elseif ($send_amount != 0 || $send_amount || !ereg('[^0-9]',$send_amount)){ if ($send_money > $fetch->money){ echo ("You havent got that much money"); }elseif ($send_money <= $fetch->money){ // Try sending money to yourself if (strtolower($to_user) == strtolower($username)){ echo ("You cannot send money to yourself"); }elseif (strtolower($to_user) != strtolower($username)){ $to_person = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$to_user'")); $otherusercash = $send_money; $otheruser = $to_user->money + $otherusercash; mysql_query("UPDATE users SET money = money-$send_money WHERE username='$username'"); mysql_query("UPDATE users SET money = '$otheruser' WHERE username='$to_person'"); $time = gmdate('Y-m-d h:i:s'); mysql_query("INSERT INTO `transfers` ( `id` , `to` , `from` , `amount` , `date` ) VALUES ('', '$to_person', '$username', '$send_amount', '$time')") or die (mysql_error()); echo "Money Sent!"; echo "<meta http-equiv=\"refresh\" content=\"0;URL=newbank.php\">"; } } } } } } } ?> <html> <head> <link rel="stylesheet" href="includes/in.css" type="text/css"> <style type="text/css"> .infobg { font-family: Arial; font-weight:normal; font-size:12px; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; background: URL(textbg1.png); font-weight:300; } .button { font-size: 12px; background:url(button.png); vertical-align: middle; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; color: #FFFFCC; height:23px; font-weight:300; border-radius: 10px; padding-bottom:2px; } </style> <title>Running-Mafia || Send Money</title> </head> <body> <form action='' name='form1'> <table width='50%' border='1' bordercolor='#000000' align='center' bgcolor='#808080' cellpadding='0' cellspacing='0' style='border-collapse: collapse'> <tr> <td colspan='2' background='header.jpg' align='center'>Send Money</td> </tr> <tr> <td> Username: </td> <td> <input type='text' name='touser' class='infobg' id='touser'> </td> </tr> <tr> <td> Ammout: </td> <td> <input name="sendmoney" class='infobg' type="text" id="send_money"> </td> </tr> <tr> <td> </td> <td> <input class="button" name="sendmoney" type="submit" id="sendmoney" value="Send Money!"> </td> </tr> </table> </form> </body> </html> Anyone see why its not sending the money? Thanks. Link to comment https://forums.phpfreaks.com/topic/213368-not-submiting-the-info/ Share on other sites More sharing options...
the182guy Posted September 14, 2010 Share Posted September 14, 2010 You need to set the forms method to POST if you want to post the variables (as you're code is expecting them as posted). E.g. <form action='' name='form1' method='post'> Link to comment https://forums.phpfreaks.com/topic/213368-not-submiting-the-info/#findComment-1110903 Share on other sites More sharing options...
dean7 Posted September 14, 2010 Author Share Posted September 14, 2010 Thanks, that stoped it going in the URL bar, but now my Submit button dont seem to work?. Link to comment https://forums.phpfreaks.com/topic/213368-not-submiting-the-info/#findComment-1110907 Share on other sites More sharing options...
rwwd Posted September 14, 2010 Share Posted September 14, 2010 Hi there, Instead of checking this:- if ($_POST['sendmoney']){ Check to see that the form is being submitted first, check what the post array contains and then progress from there, do it in incremental stages so that there is no confusion over the process: if(isset($_POST['submit']) && !empty($_POST['submit'])){ //form has been submitted, check data coming through echo "<pre>"; print_r($_POST); echo "</pre>"; } else{ //redirect back to form good to have an error handler header("Location: name_of _your_form_file_here"); exit; } Follow that, and all should work itself out.. Hopefully. Cheers, Rw Link to comment https://forums.phpfreaks.com/topic/213368-not-submiting-the-info/#findComment-1110916 Share on other sites More sharing options...
fortnox007 Posted September 15, 2010 Share Posted September 15, 2010 When your script is finished you may test your script by sending the amount of your first post to my account : Link to comment https://forums.phpfreaks.com/topic/213368-not-submiting-the-info/#findComment-1111195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.