Jump to content

Not Submiting The Info


dean7

Recommended Posts

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
Share on other sites

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
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.