ok dumb question...but I need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

ok dumb question...but I need help

Post by wesnoel »

I suck at this so if anyone want to volenteer to help I would apreciate it greatly.

OK the dumb question:

how would you write the following code so it would work under php 4.2+:

Code: Select all

<?php
if(isset($go)){
$file = "$fn.$mid.csv";
$contents = stripslashes("$date;$initials;$servicepro;$mid;$businessname;$address;$city;$state;$zip;$phone;$contact;$shippingnotes;$notes;$sup1;$qty1;$sup2;$qty2;$sup3;$qty3;$sup4;$qty4;$sup5;$qty5;$sup6;$qty6;$sup7;$qty7");
$fp = fopen("$file","a+");
fputs($fp, "$contents"); 
fclose($fp);
}

if(isset($del)){
unlink("$del");
}

if(isset($edit)){
$file = "$note";
$contents = stripslashes("$date;$initials;$servicepro;$mid;$businessname;$address;$city;$state;$zip;$phone;$contact;$shippingnotes;$notes;$sup1;$qty1;$sup2;$qty2;$sup3;$qty3;$sup4;$qty4;$sup5;$qty5;$sup6;$qty6;$sup7;$qty7");
unlink("$note");
$fp = fopen("$file","w+");
fputs($fp, "$contents"); 
fclose($fp);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Blue Slip v1.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
if(isset($go)){
echo "<meta http-equiv="refresh" content="0;URL=index.php">";
}
if(isset($del)){
echo "<meta http-equiv="refresh" content="0;URL=index.php">";
}
else{
echo "<meta http-equiv="refresh" content="2;URL=javascript:window.close()">";
}
?>
</head>
<body text="#FFFFFF" link="#FFFF00" vlink="#FFFF00" alink="#FFFF00" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
  <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
      <td align="center" valign="middle"><font size="2" color="#003366" face="Verdana">[ Blue Slip has been submitted ]</font><br>
						<font size="2" color="#003366" face="Verdana">[ Thank you !&nbsp;]</font>
    </tr>
  </table>
</div>
</body>
</html>
just a simple html form passing the data to this php script. It saves the a file for each time a user fills out the form. I then can go back and view edit or delete the file from within the browser.


Mainly just the fput section. ...and for some reason the encludes work great on my virtual host but not on my dev machine. I have read the sticky on passing variables in 4.2 but I just do not get it.

Any help would really be apreciate. I mean really really!

TIA

Wes/[
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

two questions: 1a: can stripslashes take that many arguments?
1b: shoudn't it be , instead of ;?

2:do youhave acces to a db? genereally plaintext files should be avoided if possible...the grow faster than dbs normally
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

uhh..

Post by wesnoel »

Cool a response!

OK to answer both Q's

A1. It works with or without stripslashes on my web server.
A1b. I had it as , but some of the data in the form will use , so I changed it to ;. Would | be better?

A2. It will write only once to the specified text file. The text file will then be deleted after it has been viewed.

I'm not to worried about any of that. I was testing it on my personal server at http://wesnoel.com/tasq/blue_slips/ , there you can see what I need it to do. When I tried to test it on the dev server at work nothing worked well actually it will write a blank file. I also can not view, edit or delete the files for some reason. My wesnoel.com server is running 4.1 so I know what the problen is. I just dont know how to fix it. and it is driving me crazy. If you could show me how to structure it in a better way than the vague sticky post that would be awsome.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

answer to your response to 1b:

if it wasn't working with , it wont work with anything else. and that's the only thing it MIGHT work with... because according to php.net it's supossed to take a SINGLE stringyour putting several ...wait you make several into one. hmm.. oh. i see it.

hmmm... not sure. try a loop that creates it in parts....

Code: Select all

$contents='';
foreach($_POST as $name=>$value){ $contents.="$name: $value\n\n"; }
echo $contents;
that way you'll know if it was working
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Post by wesnoel »

ok I'll try that! Crossing fingers now!
Post Reply