Updating database

software development

#1

hi, I have a form that processes customers credit cards to a processing company. once the transaction is successful, it prints to screen the information, etc. about the transaction.

In order to update my database now showing their subscription is no longer expired, I have added a form on the print screen…

print("");
print ("\n");
print ("\n");
print ("\n");
print ("\n");

then on the continue.php page (I did this just to see if $billEmail could post…

<?php $billEmail = $HTTP_POST_VARS["bill_email"]; ?>

also on continue.php I added a form with $billEmail echo to see if it was there. it does post my email address when I go to continue.php from the transaction page. Below is the form on continue.php

 

then, on continue25.php I have

<?php require_once('connection/db_connection.php'); $conn = db_connect(); if (!$conn) return 'Could not connect to database server - please try later.'; $billEmail = isSet( $_GET['bill_email'] ) ? $_GET['bill_email'] : ''; if( $billEmail == '' ) { die( 'You have not set id or it is blank. Cannot continue.' ); } echo "DEBUG: bill_email = $billEmail.
"; $expired_sql = "UPDATE customer_tbl SET expired='0' WHERE bill_email='$billEmail'"; echo "DEBUG: expired_sql = $expired_sql.
"; mysql_query( $expired_sql ) or die( mysql_error() ); $check_sql = "SELECT * FROM customer_tbl WHERE bill_email='$billEmail' AND expired='0'"; echo "DEBUG: check_sql = $check_sql.
"; $result = mysql_query( $check_sql ); $num = mysql_num_rows( $result ); if( $num == 0 ) { echo 'Done
'; } else { echo 'Failed
'; } ?>

My results on connection25.php ends up

“You have not set id or it is blank. Cannot continue.”

I am not sure where I am going wrong.


#2

okay why did u use a get http var while you have a post var for your form

please change your get pars to be post vars please, and I eveyrthing else would work as expected…

pof course this is gonna happen :@ "You have not set id or it is blank. Cannot continue."
The is nothing in the get http var so thats correct

so do what I told you and everything would be fine

btw: your code needs cleaning :slight_smile: heh not good to echo html code in php it takes more process time meaning more cpu load , try to escape as much as you can , nad its not necessarily for 2 pages for authenitcation try using only one… when a get var as ?page=2

I hope you understood if not reply and I will try helping you!

*edit: i didn’t check ur update fields yet see if ur script works or improves then u can check that part


#3

once I changed

$bill_email = isSet( $_GET[‘Bill_Email’] ) ? $_GET[‘Bill_Email’] : ‘’;
if( $bill_email == ‘’ )

to

$bill_email = $HTTP_POST_VARS[“Bill_Email”];

expired got updated in the database to ‘0’


#4

do this
instead … $billEmail = isSet( $_GET[‘bill_email’] ) ? $_GET[‘bill_email’] : ‘’;

// check if post var is sent
if ( isset($_POST[‘bill_email’]) ) {

//post sent
$bill_email = trim($_POST[‘bill_email’]);

// lets check if its not empty
if ( $bill_email == ‘’) { // empty or null

echo “E-Mail is EMPTY, contains nothing”;

} else { // not empty , contains something

echo “E-Mail Entered: $bill_email”;

}

} else {
// nothing is sent
echo “No E-Mail Header Recieved!”;
}

You can use this as well: if ( strlen($bill_email) > 0 ) echo “it has something…”;

you should use preg_replace to see if its a valid email as well