Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning form data blank.

Status
Not open for further replies.

WayneC

IS-IT--Management
Jun 22, 2001
6
GB
I have used this script to return data from a form
but I can't get it to work. Baffled.
Can anyone help?




# This script:
#
# - Takes the form contents
# - Saves the message into a temporary file
# - Calls Blat to send the mail
#


# Use the cgi unit
use cgi;

# Get the values from the form
$form = new CGI;



$subject="Mortgage Lead";
$tome="info\@domain.co.uk";
$fromme="ADP Server";
$server="smtp.domain.co.uk";



$server="smtp.domain.co.uk";
$lastname=$form->param('lastname');
$firstname=$form->param('firstname');
$dateofbirth=$form->param('dateofbirth');
$address1=$form->param('address1');
$address2=$form->param('address2');
$city=$form->param('city');
$county=$form->param('county');
$postcode=$form->param('postcode');
$firsttime=$form->param('firsttime');
$homemover=$form->param('homemover');
$remortgage=$form->param('remortgage');
$review=$form->param('review');
$std=$form->param('std');
$number=$form->param('number');
$email=$form->param('email');


$lt='<';
$gt='>';

# Output the correct header
print &quot;Content-type: text/html\n\n&quot;;

# Save the message into a text file
open (messtxt,&quot;>message.txt&quot;);

print messtxt ($lastname &quot;\n&quot;);

print messtxt ($firstname &quot;\n&quot;);

print messtxt ($dateofbirth &quot;\n&quot;);

print messtxt ($address1 &quot;\n&quot;);

print messtxt ($address2 &quot;\n&quot;);

print messtxt ($city &quot;\n&quot;);

print messtxt ($county &quot;\n&quot;);

print messtxt ($postcode &quot;\n&quot;);

print messtxt ($firsttime &quot;\n&quot;);

print messtxt ($homemover &quot;\n&quot;);

print messtxt ($remortgage &quot;\n&quot;);

print messtxt ($review &quot;\n&quot;);

print messtxt ($std &quot;\n&quot;);

print messtxt ($number &quot;\n&quot;);

print messtxt ($email &quot;\n&quot;);

close messtxt;

# Build the Blat command line and execute it

$blat=&quot;blat.exe message.txt -s \&quot;$subject\&quot; -t \&quot;$tome\&quot; -f \&quot;$fromme\&quot; -server $server\&quot; &quot;;

system($blat);

print $blat;
print &quot;<br><br>Done.<br><br>&quot;;
print &quot;Mail sent to $raddr.&quot;;
 
3 things that I see....
1 - [red]use cgi;[/red]
unless you are using a differennt CGI.pm than most people, it needs to be upper cased.
use CGI;

2 - Your print statements are a little weird. Try,
print messtxt &quot;$lastname \n&quot;;

3 - You can use the -c command line switch to see if your code will compile.
Like,
prompt>perl -c your.cgi <return>

This does not run the code, it just checks the syntax.
If your code has syntax problems, it will complain. Usually, the complaint points straight to the syntax problem. Sometimes, the interpreter has a little trouble figuring out where the problem is and you have to do a little detective work. In any case, it will let you know if your code will run, and if not, where the problem(s) likely is.

HTH



keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top