i have this code:
http://inovasphere.com/form/results.zip
what it does is turns html form contents into an fdf file
it works here:
http://inovasphere.com/form
but not here
http://americanlawfirm.net/form
i think the issue is the directory structure
when i use my filezilla to upload to inovasphere the root directory is just:
"/ "
whereas in the root directory window with the americanlawfirm site i see:
"/www "
so it is like the code cant find the folder to put the result file in. not sure
php code works on site A but not site B -- both PHP sites
Moderator: General Moderators
Re: php code works on site A but not site B -- both PHP sites
there could be many differences between your hosts. diff the output of phpinfo() on both hosts. you're looking for php version differences and libraries that are missing etc. that will get you started but we'll need more information if you expect any assistance.
Re: php code works on site A but not site B -- both PHP sites
well, fwiw, the code is exactly the same, both are php hosts
the only difference is the way the sites are structured
when i log into FTP to one i get right to the root, the other i get 'under' the root by one folder and to get to the http folder that affects what users see online i have to click on either the 'public_html' golder or the 'www' folder
i am pretty sure this is where the trouble is, i just cant figure out how to set the code to adjust for this
the only difference is the way the sites are structured
when i log into FTP to one i get right to the root, the other i get 'under' the root by one folder and to get to the http folder that affects what users see online i have to click on either the 'public_html' golder or the 'www' folder
i am pretty sure this is where the trouble is, i just cant figure out how to set the code to adjust for this
Re: php code works on site A but not site B -- both PHP sites
you dont mention what exactly is the error.
Re: php code works on site A but not site B -- both PHP sites
"Unable to create file: /home/lawfirm/public_html/form/results/posted-1.fdf"
i dont get this error with the inovasphere site
===============
there r 3 files
createFDF.php
index.php
pdf_process.php
===========
-----------------------
i dont get this error with the inovasphere site
===============
there r 3 files
createFDF.php
index.php
pdf_process.php
Code: Select all
<?php
function createFDF($file,$info){
$data="%FDF-1.2\n%âãÏÓ\n1 0 obj\n<< \n/FDF << /Fields [ ";
foreach($info as $field => $val){
if(is_array($val)){
$data.='<</T('.$field.')/V[';
foreach($val as $opt)
$data.='('.trim($opt).')';
$data.=']>>';
}else{
$data.='<</T('.$field.')/V('.trim($val).')>>';
}
}
$data.="] \n/F (".$file.") /ID [ <".md5(time()).">\n] >>".
" \n>> \nendobj\ntrailer\n".
"<<\n/Root 1 0 R \n\n>>\n%%EOF\n";
return $data;
}
?>
Code: Select all
<?php
include dirname(__FILE__).'/pdf_process.php';
echo '<?xml version="1.0" encoding="iso-8859-1"?>',"\n"; // because short_open_tags = On causes a parse error.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="A PHP solution to filling a PDF file's form fields with data from a submitted HTML form." />
</head>
<body>
<div id="container">
<?php
if(isset($CREATED)){
?>
<a href="<?php echo str_replace(dirname(__FILE__).'/','',$fdf_file) ?>">download</a>
<?php
}
?>
<div>
</div>
<div>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
<table cellpadding="3" cellspacing="0" border="0">
<tr><td>Name</td><td><input type="text" name="__NAME__" value="<?php if(isset($_POST['__NAME__'])) echo $_POST['__NAME__']; ?>" /></td></tr>
<tr><td>Title</td><td><input type="text" name="__TITLE__" value="<?php if(isset($_POST['__TITLE__'])) echo $_POST['__TITLE__']; ?>" /></td></tr>
<tr><td>Email</td><td><input type="text" name="__EMAIL__" value="<?php if(isset($_POST['__EMAIL__'])) echo $_POST['__EMAIL__']; ?>" /></td></tr>
<tr><td>Address</td><td><input type="text" name="__ADDRESS__" value="<?php if(isset($_POST['__ADDRESS__'])) echo $_POST['__ADDRESS__']; ?>" /></td></tr>
<tr><td>City</td><td><input type="text" name="__CITY__" value="<?php if(isset($_POST['__CITY__'])) echo $_POST['__CITY__']; ?>" /></td></tr>
<tr><td>State</td><td><input type="text" name="__STATE__" value="<?php if(isset($_POST['__STATE__'])) echo $_POST['__STATE__']; ?>" /></td></tr>
<tr><td>Zip</td><td><input type="text" name="__ZIP__" value="<?php if(isset($_POST['__ZIP__'])) echo $_POST['__ZIP__']; ?>" /></td></tr>
<tr><td>Phone</td><td><input type="text" name="__PHONE__" value="<?php if(isset($_POST['__PHONE__'])) echo $_POST['__PHONE__']; ?>" /></td></tr>
<tr><td>Fax</td><td><input type="text" name="__FAX__" value="<?php if(isset($_POST['__FAX__'])) echo $_POST['__FAX__']; ?>" /></td></tr>
</table>
<input type="submit" />
</form>
</div>
<div>
</div>
<div>
</div>
<div>
</body>
</html>
-----------------------
Code: Select all
<?php
require_once 'createFDF.php';
$pdf_file='http://inovasphere.com/form/test.pdf';
// allow for up to 25 different files to be created, based on the minute
$min=date('i') % 25;
$fdf_file=dirname(__FILE__).'/results/posted-'.$min.'.fdf';
if(isset($_POST['__NAME__'])){
$_POST['__CSZ__']=$_POST['__CITY__'].', '.
$_POST['__STATE__'].' '.
$_POST['__ZIP__'];
// get the FDF file contents
$fdf=createFDF($pdf_file,$_POST);
// Create a file for later use
if($fp=fopen($fdf_file,'w')){
fwrite($fp,$fdf,strlen($fdf));
$CREATED=TRUE;
}else{
echo 'Unable to create file: '.$fdf_file.'<br><br>';
$CREATED=FALSE;
}
fclose($fp);
}
?>
Re: php code works on site A but not site B -- both PHP sites
are the permissions different on the 'results' directory on each host.
Re: php code works on site A but not site B -- both PHP sites
yes, they are identical
Re: php code works on site A but not site B -- both PHP sites
can you try just to write something with file_put_contents('/fullpath/test.txt', 'test') and make sure a file get created in the right directory