Saving, using POST and $variable.

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

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

installing apache/php is that simple that I say no atm ;)
for syntax checking you even do not need webserver software.
Just download php from php.net and invoke

Code: Select all

php -l <scriptfilename>
Just try it, it's really simple.....
hatman
Forum Newbie
Posts: 13
Joined: Sat Nov 09, 2002 4:46 pm

Post by hatman »

OK I'll give it a try.
What does the -l stand for? And how do i invoke it? in a browser? or can I launch a test window or something?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you have to invoke it at the command line (dos box for windows ;) )
-l ...hmmm, maybe lint - don't really know. It will just perform a syntax check without executing the script

http://www.php.net/manual/en/features.commandline.php
-l Syntax check only (lint)
yo, lint ;)
hatman
Forum Newbie
Posts: 13
Joined: Sat Nov 09, 2002 4:46 pm

Post by hatman »

doooohh...
Volka! I got it!
If you look at the code what is OBVIOUSLY wrong?

Code: Select all

<form action="<?php echo $page; ?>.php" method="post">
what is the page being updated doing there?
nothing executes the script!
In short:
The file where the executable code resides is named update.php right

Code: Select all

<form action="update.php" method="post">
Just a little harmless mistake hah? :mrgreen:

Thanks so much Volka for staying with me!
hatman
Forum Newbie
Posts: 13
Joined: Sat Nov 09, 2002 4:46 pm

Post by hatman »

Here's the full script, just in case anybody is interested:

Code: Select all

&lt;?php 
   include("class.ewp.php"); 
   
   if($_GET&#1111;'page'] == '')
   $page = $_POST&#1111;'page'];
   else
   $page = $_GET&#1111;'page'];

   $myEWP = new EWP; 
    
   if(@$_POST&#1111;"save"] == "true") 
   { 
      $fileContent = $myEWP-&gt;GetValue(false); 
      $fp = fopen("$page.php", "w"); 
      fputs($fp, $fileContent); 
      fclose($fp); 
      echo "Content saved!&lt;br&gt;&lt;br&gt;&lt;a href='$page.php'&gt;Continue&lt;/a&gt;"; 
   } 
   else 
   { 
      $fp = fopen("$page.php", "rb"); 
      while(!feof($fp)) 
      { 
         $data .= fgets($fp, 1024); 
      } 
      $myEWP-&gt;SetValue($data); 
?&gt; 
&lt;form action="update.php" method="post"&gt;
&lt;input type="hidden" name="page" value="&lt;?php echo $page; ?&gt;"&gt;
&lt;input type="hidden" name="save" value="true"&gt;
&lt;?php $myEWP-&gt;ShowControl(400, 300, "imgs"); ?&gt;
&lt;br&gt;&lt;input type="submit" value="Save"&gt;
&lt;/form&gt;
&lt;?php
   }
?&gt;
Post Reply