HTML Code:
1. ‘encrypt’ was a typo for ‘enctype’.
form script
1. Nearly all code composing and editing is done with notepad++. However, I have occasionally cut&pasted code from the web into MS Word, and from there, after editing, into notepad++ files.
You may have discovered a concern that sometimes arises. Mixed varieties of code have infrequently been noted to display questionably in notepad++. A part of the form script, TEST_07c.php, did this until I cut those portions from the current script. They were text that printed dark black instead of the usual blue tint used by notepad++. I haven’t found the cause yet, but have assumed it’s a setting in my notepad++ that I don’t know about.
Have not yet found the’ “curly quotes” mixed in with the code’ you’ve alluded to.
PHP Code.
Yes, (E_ALL) is better.
- if() statement
The if($sndbxRGSTRTN) snippet was lifted from the larger mother code, but the definition $sndbxRGSTRTN was overlooked.
The point of this code is to find clues as to why <form> with its action directed to PayPal sandbox IPN tester doesn’t send anything. So I put together several simple tests:
a) Do variables set before the form is reached get loaded into the form?
b) Do variables within the form get set?
c) Can they be detected in the same script following the form? I now understand that the answer is NO because action only submits the form and returns nothing. I had previously tried to var_export $_POST from within & following the form code.
d) Can a form be made autosubmitting by setting its ‘submit’ value = “submit”? So far it hasn’t succeeded so NO is suspected, but previous code errors may have preempted a test.
listen_2.php script
Found missing closure of the 2nd fputs command.
All suggestions made and tested with the following results.
The error messages:
1.) This error was received once for each variable in the form.
Notice: Undefined index: first_name in /home/vg010web02/68/65/2926568/web/auxlib/web07/HTMLpages/listen_2.php on line 35
So, evidently variables are not being set in the <form> script, but the form is autosubmitted.
The edited scripts follow:
<?php
// TEST_07cTest.php
// Preselected data are used in a form submitted to listen_2.php for processing.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" “http://www.w3.org/TR/html4/loose.dtd” >
<HTML>
<HEAD>
<META http-equiv="charset" content_type=text/html>
<META http-equiv="charset" content="utf-8">
<TITLE> RGSTRTN_07cTest.php </TITLE>
</HEAD>
<BODY>
<?PHP
error_reporting(E_ALL ^ E_NOTICE);
require_once $_SERVER['DOCUMENT_ROOT']."/auxlib/MyErrorHandler.php";
require_once $_SERVER['DOCUMENT_ROOT']."/auxlib/web07/InclReq/config.php";
require_once $_SERVER['DOCUMENT_ROOT']."/lib/phpmailer/phpmailer5_6/class.phpmailer-lite.php";
$time_stamp = date('m/d/y h:i:s a');
$fp1 = fopen('SmpSbxLog.txt', "a");
$notify_email = 'name@domain.net';
$sndbxRGSTRTN = true;
echo "<p>L.23 TEST_07cTest, $time_stamp <p>";
fputs($fp1, "\n L.24 TEST_07cTeST, $time_stamp \n");
If($sndbxRGSTRTN) {
$first_name = 'Bobb';
$last_name = 'Presets';
$item_name = 'HI_txt';
$amount = '1.50';
$invoiceNo = '12ab';
}
?>
<form action="./listen_2.php" enctype="text/plain" method=POST />
<input type=hidden name=item_name value='Book' />
<input type=hidden name=amount value="<? echo $amount ?>" />
<input type=hidden name=invoice value="<? echo $invoiceNo ?>" />
<input type=hidden name=rm value='2' />
<input type=hidden name=first_name value="<? echo $first_name ?>"/>
<input type=hidden name=last_name value="<? echo $last_name ?>"/>
<input type=hidden name=email value="<? echo $mail_notify?>"/>
<input type=submit name=submit value="submit" />
</form>
<?PHP
echo "L.49 TEST_07cTest, item_name = $item_name, last_name = $kast_name <p>";
fclose($fp1);
?>
</BODY>
</HTML>
<?php
// listen_2.php listens for <form> data from TEST_07cTest.php
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" “http://www.w3.org/TR/html4/loose.dtd” >
<HTML>
<HEAD>
<META http-equiv="charset" content_type=text/html>
<META http-equiv="charset" content="utf-8">
<TITLE> RGSTRTN_07cTest.php </TITLE>
</HEAD>
<BODY>
<?php
error_reporting(E_ALL);
require_once $_SERVER['DOCUMENT_ROOT']."/cnnct2mysql.php";
require_once $_SERVER['DOCUMENT_ROOT']."/auxlib/web07/InclReq/config.php";
$fp1 = fopen('SmpSbxLog2.txt', "a");
$_SERVER['DOCUMENT_ROOT']."/lib/phpmailer/phpmailer5_6/class.phpmailer-lite.php";
$time_stamp = date('m/d/y h:i:s a');
$mail_notify = 'name@udomain.net';
fputs($fp1, "L.20 listen_2.php \n");
$req = 'cmd=notify-validate';
$req1 = $req;
// A. Read POST from TEST_07cTest.php
foreach ($_POST as $key => $value)
{
$req1 .= "&$key=$value"; //unmodified version of $req
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
fputs($fp1, "L.33 listen_2.php, $time_stamp \n \$req= \n".var_export($req,$result=true). "\n");
fputs($fp1, "L.34 listen_2.php, $time_stamp \n \$req1=\n".var_export($req1,$result=true)."\n");
// C. Assign POST'ed vars to local vars. //
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$item_name = $_POST['item_name'];
$invoice = $_POST['invoice'];
$amount = $_POST['amount'];
$item_name = $_POST['item_name'];
mail($notify_email,"L.42, \$_POST[] data, $time_stamp <p>\n","<pre>".
var_export($_POST, true)."</pre>");
// L. Save data in paypal_payment_info_2 table //
$query = "INSERT INTO paypal_payment_info_2
(
last_name, item_name, amount, email,
first_name, invoice, mc_gross
)
values
(
'".$last_name."', '".$item_name. "', '".$amount."',
'".$email. "', '".$first_name."', '".$invoice."' ,
'".$mc_gross. "'
)";
$result = mysql_query($query)
or exit(mail($notify_email, "Insert in paypal_payment_info_2 failed"
,mysql_error() . mysql_errno()));
fclose ($fp1);
exit;
?>
</BODY>
</HTML>
I much appreciate your ideas.
u-sit