Subtract From and Update mysql database field via php

Hello Peeps,
I am trying to do the following

  1. receive input via a form
  2. From the submitted variables, check the email in the database table and then pick the number field i want to subtract from
  3. subtract the value from the submitted form from the value in the amount field in the database (I want to verify that the submitted value is less than the value in the database field)
  4. Update the database with the value of the subtraction…
  5. redirect to another page

I have written a script and when i run it, it does nothing… I need experienced php programmers to please take a look and modify if necessary… Thank you for your time and kind consideration…
The script is below


$host=“localhost”; // Host name
$username=“root”; // Mysql username
$password=“”; // Mysql password
$db_name=“”; // Database name

//Connect to server and select databse.
mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect to server”);
mysql_select_db(“$db_name”)or die(“cannot select DB”);

// value sent from form

// table name

// retrieve password from table where e-mail = $Email(
$sql=“SELECT account_balance FROM $tbl_name WHERE email=‘$Email’”;
mysql_query(“UPDATE client SET account_balance = ‘$new_val’ WHERE email=‘$Email’”);

header(“Location: Processingpage1.htm”);


Edit/Delete Message

you just need to do some basic debugging.

this is twice as inefficient as it needs to be

you don’t have to retrieve the balance first before updating it, you can just update it

UPDATE client 
   SET account_balance = account_balance - $_POST['AmtTransferred'];