Need Help with .CGI Script

First of all I'm new at scripting languages. However, I think I understand most of what I'm reading. My question is: Should these scripts work?
When I try and test I get:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@lonestardivers.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Patrick, I am using DzSoft Perl Editor to edit and save the scripts. I originally uploaded through the FrontPage 'Publish' function, buth then after having problems I deleted the files from my website and using FTP uploaded the files again. When viewing the files via my webservers control panel it shows me that it is a perl script file in ascii text; for the file inpx.cgi. When viewing the inpx_config.pl is shows the .pl files to be ascii text with CR/LF. These were also edited and save using DzSoft Perl Editor.

I know MODULES is a sub-folder under IPNX. The folder structure is:/public_html/scgi-bin/inpx/MODULES. With the script file inpx.cgi location in the /public_html/scgi-bin/inpx and the 2 .pl files (inpx_config.pl and inpx.pm) in the /public_html/scgi-bin/inpx/MODULES

- file corruption (if you edit on Windows but serve on Unix/Linux, make sure to save with Unix line feeds in your text editor)

Patrick BreitenbachPayPal, Inc.Dev Net: https://www.paypal.com/pdn<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">[br] First error:[br]$receiver_email = $hash_data{'receiver_email'};$receiver_email =~ s/\s//g; - this returns an error and appears to be a duplicate of the preceding line with different data for the string $receiver_email. I commented this line out. Can you tell me if it's required?The 2nd error:[br]if ($receiver_email ne $email_admin) {[br] errors with uninitialized value in string ne[br] I didn't think ne was a string; however I also do not know what it is. I thought it meant 'not equal' based on the balance of the context. Remember I'm still learning.The 3rd error:[br]$msg = "Paypal has sent a transaction that does not belong to $domain. Email name received = $receiver_email";[br]Here I get an uninitialed value in concatenation (.) or string. Can you help with any of these?

------------------
$msg = "Paypal has sent a transaction that does not belong to $domain. Email name received = $receiver_email";

Here I get an uninitialed value in concatenation (.) or string.
------------------

I think that the period in the sentence is throwing you off. It is usualy used to combine two strings together:

$A = 'A';
$B = 'B';
$C = $A . $B;
print $C;

Would give you: AB

Try escaping it out by putting a back slash (\) directly before it.

Your first error:
This command take in the string from $receiver_email and removes all white space characters. Not sure why it is throwing an error.

Your second error:
Yes, you are correct, ne means 'not equal' and it is used to check if two strings of characters are 'not equal'. Again though, I don't see why this is an error. And you can probably take it out for testing because all it seems to do is make sure that this program is recieving money meant for you.

------------------$msg = "Paypal has sent a transaction that does not belong to $domain. Email name received = $receiver_email";

Here I get an uninitialed value in concatenation (.) or string.------------------

I think that the period in the sentence is throwing you off. It is usualy used to combine two strings together:

$A = 'A';$B = 'B';$C = $A . $B;print $C;

Would give you: AB

Try escaping it out by putting a back slash (\) directly before it.

Your first error:This command take in the string from $receiver_email and removes all white space characters. Not sure why it is throwing an error.

Your second error:Yes, you are correct, ne means 'not equal' and it is used to check if two strings of characters are 'not equal'. Again though, I don't see why this is an error. And you can probably take it out for testing because all it seems to do is make sure that this program is recieving money meant for you.

David,Thanks for the input. It also explains why when I inadvertently removed a few . (periods) one feature quit working. I compared the original text to the modified text and found I had deleted the period on 2 lines and it affected the program.

I tried the \. entry in that line but the error persisted. I then broke the line down from:

$msg = "Paypal has sent a transaction that does not belong to $domain. Email name received = $receiver_email";

To:

$msg = "Paypal has sent a transaction that does not belong to " . "$domain" . ". " . "Email name received = " . "$receiver_email";

the new line passed. I thought the "." quoted period should work, however it didn't the way it was first used.

Anyway, here is where I stand. I have ipnx.cgi installed and the proper folders and support files it requires and/or uses. I have used Dave VanAbel's test site for IPN, on Perslsources.com to test the program. When I execute a test, I get an OK back. I get a file put into the "data" directory and a file put into the "history" directory. Based on how the .cgi script is written my history file is named yyyymm.txt and appends each entry. The data file is based on the txn_id.txt and each one it creates is new. (except if I do not pick a new txn_id then this files appends. There is also a "log" directory where error logs are placed. During testing at the free test site, I did not receive any error logs. I also got the appropriate emails for buyer and merchant.

When I do a test buy through PayPal, I get an error log and no data or history logs. Checking the code this seems correct if there are errors. However, I do not know why it's erroring. Well I kind of understand. Looking at the error log there are 35 pairs of data seperated by !!. The pairs of data are messed up. Some pairs are missing their mates, most just have the wrong mate.Examplepayer_email=Completed=Payer_emailWeatherford=business (Weatherford should be address_city)unverified=mc_currencyUSA-mc_gross

and so on.... The more I program the more I understand, but with no books on PERL programming, I've had to just used my knowledge of basic, html and a few other programming languages to cipher this code.

What part of the code determines how to mate up what is received from PayPal and then sends it backs correctly?

======================================================================# READ POST from PayPal and add 'cmd'# - stated in the code, but do these 2 lines read the entire data file sent from paypal? if so, how does it parse the data?======================================================================

======================================================================# POST BACK to PayPal# - also stated in the code, but again how many of these lines do the work? What in the code guarantees that what was received will be sent back correctly?======================================================================

======================================================================While reading the next section, I might have found my problem. I will have to make some changes on paypal to verify. My primary email address is not the one payments are send to, I can change that and make it my primary. I'll get back with you.

commented out, which may be throwing your order off.
Also, check into the line:

$invoice = ($hash_data{'quantuty'});

Something fishy with that statement.

Next...You wrote:

-------------------------
# READ POST from PayPal and add 'cmd'# - stated in the code, but do these 2 lines read the entire data file sent from paypal? if so, how does it parse the data?
======================================================================

David,Thanks for replying. I corrected 'quantuty', hell I can't type even though I've been using a keyboard for 30 years. I figured the rest, the way you did, about the parsing, etc. My biggest problem was cured when I finally figured out that my return html screen that is called was trying to be posted to from PayPal and they provided code that changed the POST to GET. The script is working with many new changes including better mail messages to both myself and the buyer. I'll keep working on the script until I'm happy, but at least it now works.I do have a question.If PayPal POSTS to my HTML 'return' page, how can I accept that post and make the 'return html page' a printable receipt?I would have to change the current layout which is just a text html screen that states the transaction was completed. I could layout a nice Invoice Style Screen that allowed for me to populate name, address, ext, and purchase information such as Item Name, Price, quantity, tax, s&h, total.I would guess that there is html code similar to the perl code that would accept that POST from PayPal. Do you know how I can do this?

commented out, which may be throwing your order off.Also, check into the line:

$invoice = ($hash_data{'quantuty'});

Something fishy with that statement.

Next...You wrote:

-------------------------# READ POST from PayPal and add 'cmd'# - stated in the code, but do these 2 lines read the entire data file sent from paypal? if so, how does it parse the data?======================================================================

I would then be able to place the variables in my invoice table to create a populated invoice? I understand that what I have shown here would basically work, however not being schooled in html, I would think some of the commands would be different. I'm looking for enough information as shown in the code above to make this work. Can anyone provide that information? Thanks for taking the time to help.

One more thing, do varaibles have to be initialized in html and if so what is the code arrangement for that?

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by paypal_pb[br]The POST to the "return" URL is identical to the IPN. You can use the same or a similar script.

HTML and PERL are totaly different.
You cannot put PERL coding (except Server-Side Includes) into HTML.
Perl script ahve to be put in a *.pl or *.cgi file on their own, and your server has to be able to run PERL scripts.