hello… i have a question to a problem i’ve been trying to figure out for a month.
i’m working on a “bidding” script that i can’t get to work.
i set mc_gross to 4.00 from the paypal ipn. now once “[mc_gross]” reaches ‘0.00’ it’s meant to
go to “pay.html”, but instead it keeps saying “bid placed” when there is no money left in mc_gross.
please tell me what i’m doing wrong.
thank you in advance!
members table:
<?php mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_Select_db("mydatabase") or die(mysql_error()); mysql_query("CREATE TABLE members( id INT NOT NULL auto_increment, PRIMARY KEY(id), first_name VARCHAR(100), last_name VARCHAR(100), username VARCHAR(100), password VARCHAR(100), payer_email varchar(100), mc_gross FLOAT(6,2) )")or die(mysql_error()); echo "table created!"; ?>bids table:
<?php mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_Select_db("mydatabase") or die(mysql_error()); mysql_query("CREATE TABLE bids( id INT NOT NULL auto_increment, PRIMARY KEY(id), highbidder VARCHAR(100), payer_email varchar(100), seller VARCHAR(100), seller_email VARCHAR(100), weight varchar(100), composition varchar(100), color VARCHAR(100), mc_gross FLOAT(6,2) )") or die(mysql_error()); echo "table created!"; ?>login script:
<?php session_start(); $host="localhost"; $username="user"; $password="pass"; $db_name="mydatabase"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $_SESSION['id'] = $_GET['id']; $_SESSION['payer_email'] = $_GET['payer_email']; $_SESSION['mc_gross'] = $_GET['mc_gross']; session_register("id"); session_register("payer_email"); session_register("mc_gross"); session_register("username"); session_register("password"); $_SESSION['mc_gross'] = $_POST['mc_gross']; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; $_SESSION['payer_email'] = $_POST['payer_email']; $_SESSION['mc_gross'] = $_POST['mc_gross']; $mc_gross = $_POST['mc_gross']; $username = $_POST['username']; $password = $_POST['password']; $payer_email = $_POST['payer_email']; $_SESSION['mc_gross'] = $mc_gross; $_SESSION['username'] = $username; $_SESSION['password'] = $password; $_SESSION['payer_email'] = $payer_email; $data=mysql_query("SELECT * FROM members WHERE username = '$username' AND password = '$password'") or die(mysql_error()); if($info=mysql_fetch_array($data)){ print $info['username']; print ""; print $info['password']; print "
"; print $info['payer_email']; print "
"; print $info['mc_gross']; print "
"; print 'Go to Auctions'; print "
"; print 'Post an Auction'; print "
"; }else{ header('Location:failed.html'); } $data2 = mysql_query("SELECT * FROM bids WHERE payer_email = '$_SESSION[payer_email]'") or die(mysql_error()); while($info = mysql_fetch_array($data2)){ print "These are your Bids!"; print "
"; print $info['highbidder']; print "
"; print $info['payer_email']; print "
"; print $info['seller']; print "
"; print $info['seller_email']; print "
"; print $info['weight']; print "
"; print $info['composition']; print "
"; print $info['color']; print "
"; print "
"; } ?>
this next script uses the paypal IPN to load the value into “[mc_gross]”… the value being $4.00.
ipn.php:
<?php session_start(); $host="localhost"; $username="user"; $password="pass"; $db_name="mydatabase"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $mc_gross = $_POST['mc_gross']; $last_name = $_POST['last_name']; $payer_email = $_POST['payer_email']; mysql_query("UPDATE members SET mc_gross = '$mc_gross' WHERE last_name = '$last_name' AND payer_email = '$payer_email'") or die(mysql_error()); ?>this next script is supposed to go to “pay.html” when the value in “[mc_gross]” decrements to 0.00… it’s not doing this for
some reason. it keeps on going to “bid placed”.
output-bids.php:
<?php session_start(); mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("mydatabase") or die(mysql_error()); if($_SESSION[mc_gross] == 0.00){ header ('LOCATION:pay.html'); }else{ mysql_query("UPDATE members SET mc_gross = mc_gross - 1 WHERE id = '$_GET[id]'") or die(mysql_error()); print "bid placed"; } ?>if the “else” statement is successful it’s supposed to decrement “[mc_gross]” by $1.00 each time… instead it keeps
saying “bid placed” even when “[mc_gross]” drops to 0.00.
i’ll add the rest of the code to output-bids.php when i can get the if/else working.
thank you for any help!
