Hello!
I am putting up a free donation page up for a local government official. I am using a script I have used on servers that have PHP 5 set up on them. The server that the official has for himself houses PHP4 (thru earthlink). I have looked thru the PHP4 manual to find differences that mattered, but I have come up empty handed. The script below is a simple php script that grabs post info, does some error checking, writes a record to a file, and sends the user off to a protected payment site.
Why won't it work in PHP4? When my html form page calls the php file, the browser screen just goes white. Please NOTE that I have changed some of the links to "official" or "nstuff" to keep personal info private.
<?php
$fname = $_POST['fname']; //Required
$lname = $_POST['lname']; //Required
$address1 = $_POST['address1']; //Required
$city = $_POST['city']; //Required
$state = $_POST['state']; //Required
$zip = $_POST['zip']; //Required
$hphone = $_POST['hphone'];
$wphone = $_POST['wphone'];
$email = $_POST['email']; //Required
$occu = $_POST['occu']; //Required
$emp = $_POST['emp']; //Required
$baddress = $_POST['baddress'];
$bcity = $_POST['bcity'];
$bstate = $_POST['bstate'];
$bzip = $_POST['bzip'];
$support = $_POST['support']; //CB
$houseparty = $_POST['houseparty']; //CB
$contrib = $_POST['contrib']; //CB
$selectamount = $_POST['selectamount']; //Selection
$otheramount = $_POST['otheramount'];
//WebLink Info//////////////
$login_wf = "official";
//Give file path to string.
$file_name = "payfile.txt";
$ts = date("m-d-Y g:ia"); //Get GMT timestamp -- 8 hours ahead pac std time.
if($fname == "" || $lname == "" || $emp == "" || $occu == "" || $email == "" || $address1 == "" || $city == "" || $state == "" || $zip == "")
{
header("Location: http://www.official.com/donate_err.html");
exit();
}
else
{
if($otheramount != "")
{
$otheramount = str_replace("$", "", $otheramount);
$otheramount = trim($otheramount);
if(!is_numeric($otheramount))
{
header("Location: http://www.official.com/donate_err.html");
exit();
}
if($otheramount > 6400)
{
header("Location: http://www.official.com/donate_err.html");
exit();
}
$amount_wf = $otheramount;
}
else
{
if($selectamount == "other")
{
header("Location: http://www.official.com/donate_err.html");
exit();
}
$amount_wf = $selectamount;
}
$hdr_entry="Location: https://secure.authorize.net/nstuff?x_login=".$login_wf
."&x_show_form=PAYMENT_FORM"
."&x_first_name=" .$fname
."&x_last_name=" .$lname
."&x_address=" .$address1
."&x_city=" .$city
."&x_state=" .$state
."&x_zip=" .$zip
."&x_email=" .$email
."&x_amount=" .$amount_wf;
//Set up record entry for donation list file.
$record = "|"
.$ts."|"
.$fname."|"
.$lname."|"
.$address1."|"
.$city."|"
.$state."|"
.$zip."|"
.$hphone."|"
.$wphone."|"
.$email."|"
.$occu."|"
.$emp."|"
.$baddress."|"
.$bcity."|"
.$bstate."|"
.$bzip."|"
.$support."|"
.$houseparty."|"
.$contrib."|"
.$amount_wf."\n";
//Open file for appending. If file does not exist, file is created.
$don_file = fopen($file_name, 'a');
if(!$don_file)
{
exit("Error: File could not be opened");
}
//Write file_entry to file.
fwrite($don_file, $record);
//Close the file.
fclose($don_file);
header($hdr_entry);
exit();
}
?>