Editing an existing .xls on a server

Topics: User Forum
Jul 21, 2012 at 12:05 PM
Edited Jul 21, 2012 at 12:18 PM

Hey,

I try to explain my problem as best as I can, I hope you can understand it, because english is not my native language.

I created a simple form in html over 3 pages and at the end, I want to write the results in an existing xls file.

I use php sessions to get the data over the 3 pages and it's working fine in a VM with an apache server. But only there.

Now I uploaded it to a server which has php functionality, but there the xls file is only expanded with a timestamp which the form creates at the last page. The rest of the data will not be copied into the existing xls file. Is there a problem with the server, the sessions or did I forget something else? Do I have to edit something for the server?

http://joker313.lima-city.de/Umfrage1.html

This is my form, I hope someone can help me :)

Coordinator
Jul 21, 2012 at 10:50 PM

Without seeing any code, it's extremely difficult to identify any problem.

Have you tried debugging your $_SESSION data before writing it to a PHPExcel object?

Are you running with PHP error logging? what error levels are set?

Jul 22, 2012 at 8:29 AM

Ok, here is my code:

 

Page 1 is only html with different types of radio buttons and checkboxes.

Page 2 starts the session and saves the data from page 1 into session variables

 

<?php
session_start();
$_SESSION[aufmerksam]=$_POST[aufmerksam];
$_SESSION[woaufmerksam]=$_POST[woaufmerksam];
$_SESSION[warum]=$_POST[warum];
$_SESSION[erwartung]=$_POST[erwartung];
$_SESSION[gefallen]=$_POST[gefallen];
$_SESSION[info]=$_POST[info];
$_SESSION[weiterempfehlen]=$_POST[weiterempfehlen];
?>

 

After the php header there are more checkboxes and radio buttons.

Page 3 has a php header, too.

 

<?php  
session_start();
$_SESSION[st�ndige]=$_POST[st�ndige];
$_SESSION[Ausstellungen]=$_POST[Ausstellungen];
$_SESSION[bedeutend]=$_POST[bedeutend];
$_SESSION[Bauma�nahmen]=$_POST[Bauma�nahmen];
$_SESSION[ersterbesuch]=$_POST[ersterbesuch];
$_SESSION[Besuch]=$_POST[Besuch];
$_SESSION[infokultur]=$_POST[infokultur];
$_SESSION[wieinfo]=$_POST[wieinfo];
$_SESSION[infoInternet]=$_POST[infoInternet];
$_SESSION[erfahrenInternet]=$_POST[erfahrenInternet];
$_SESSION[zurechtInternet]=$_POST[zurechtInternet];
$_SESSION[ticketverkaufgenutzt]=$_POST[ticketverkaufgenutzt];
$_SESSION[ticketverkaufnutzen]=$_POST[ticketverkaufnutzen];
$_SESSION[Ufercard]=$_POST[Ufercard];
$_SESSION[Mitglied]=$_POST[Mitglied];
?>

And there follows again more checkboxes and radio buttons.

The last page includes the phpexcel part, I deleted some code from the phpexcel writing area, so it's easier to understand.

<?php 
session_start();

?>
<html>
	<head>
		<title>Umfrage</title>
		<link rel="stylesheet" type="text/css" href="aussehen.css" />
	</head>
	<body>
	<input type="hidden" name=<?echo session_name();?> value=<?echo session_id();?>>
<?php
require_once 'Classes/PHPExcel/IOFactory.php';
$file='Classes/Besucherumfrage_Staedel.xls';
$objReader = PHPExcel_IOFactory::createReaderForFile($file);
$objPHPExcel = $objReader->load($file);
$objPHPExcel->setActiveSheetIndex(0);
$sheet = $objPHPExcel->getActiveSheet();
$highestRow = $sheet->getHighestRow();
$row=$highestRow+1;

$sheet->setCellValue('B'.$row, $erwartung);	
$sheet->setCellValue('AY'.$row, $st�ndige);
$sheet->setCellValue('AZ'.$row, $Ausstellungen);
$sheet->setCellValue('BA'.$row, $bedeutend);
$sheet->setCellValue('BB'.$row, $Bauma�nahmen);
$sheet->setCellValue('BC'.$row, $ersterbesuch);
$sheet->setCellValue('BD'.$row, $Besuch);
$sheet->setCellValue('BE'.$row, $infokultur);
$sheet->setCellValue('BF'.$row, $wieinfo);
$sheet->setCellValue('BG'.$row, $infointernet);
$sheet->setCellValue('BH'.$row, $erfahrenInternet);
$sheet->setCellValue('BI'.$row, $zurechtInternet);
$sheet->setCellValue('BJ'.$row, $ticketverkaufgenutzt);
$sheet->setCellValue('BK'.$row, $ticketverkaufnutzen);
$sheet->setCellValue('BL'.$row, $Ufercard);
$sheet->setCellValue('BM'.$row, $Mitglied);

$sheet->setCellValue('BN'.$row, $AnreiseAusstellung);
$sheet->setCellValue('BO'.$row, $Anreise);

	
	else 
	{
	$sheet->setCellValue('CO'.$row, '0');
	}
	}
				for ($i=0; $i<$erg; $i++) {
	if ($InfoAusstellungen[$i]=="Sonstiges") {
	$sheet->setCellValue('CP'.$row, '1');
	$i=$erg;
	}
	else 
	{
	$sheet->setCellValue('CP'.$row, '0');
	}
	}
	
$sheet->setCellValue('CQ'.$row, $besucht);
$sheet->setCellValue('CR'.$row, $gefallenmeinung);
$sheet->setCellValue('CS'.$row, $verbessernmeinung);
$sheet->setCellValue('CT'.$row, $name);
$sheet->setCellValue('CU'.$row, $Adresse);
$sheet->setCellValue('CV'.$row, $email);
$sheet->setCellValue('CW'.$row, $Verlosung);
$sheet->setCellValue('CX'.$row, $Newsletter);

$aktuelles_datum = date("d.m.Y"); 
$aktuelle_uhrzeit = date("H:i"); 
$date=$aktuelles_datum.(' - ').$aktuelle_uhrzeit;

$sheet->setCellValue('CY'.$row, $date);

	$starting_pos = ord('C');
$index_pos = 0;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save($file);


?>

<div id="Bild">
  
  <img src="staedel.jpg">
  
</div>
<div id="Umfrage">
Vielen Dank f�r Ihre Teilnahme!
</div>
	</body>
</html>

And now, the xls don't get the data from the other pages, it will be only expanded with the date which is created at the last site.


I can try to debug my session (I have to check it in the internet what I have do). Sorry for my simple code but I am in the learning process and it's my first time with such a 'complex' code.

And I check out the PHP error logging.

Thanks for your ideas.

 

 

 

 

Jul 22, 2012 at 8:39 AM

I added a debugging code to my pages:

<?php 
error_reporting( E_ALL );
ini_set( 'display_errors', 1);
date_default_timezone_set('Europe/Berlin');
session_start();
?>

I get now this error code when I try to fill it my forms in the VM:


Notice: Use of undefined constant ständige - assumed 'ständige' in C:\winfo\xampp\htdocs\Umfrage3.php on line 6

Notice: Use of undefined constant ständige - assumed 'ständige' in C:\winfo\xampp\htdocs\Umfrage3.php on line 6

Notice: Use of undefined constant Ausstellungen - assumed 'Ausstellungen' in C:\winfo\xampp\htdocs\Umfrage3.php on line 7

Notice: Use of undefined constant Ausstellungen - assumed 'Ausstellungen' in C:\winfo\xampp\htdocs\Umfrage3.php on line 7

Notice: Use of undefined constant bedeutend - assumed 'bedeutend' in C:\winfo\xampp\htdocs\Umfrage3.php on line 8

Notice: Use of undefined constant bedeutend - assumed 'bedeutend' in C:\winfo\xampp\htdocs\Umfrage3.php on line 8

Notice: Use of undefined constant Baumaßnahmen - assumed 'Baumaßnahmen' in C:\winfo\xampp\htdocs\Umfrage3.php on line 9

 

How can I solve that the server has not to assume my variables?

 

Thanks for the help :)