php on windows

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
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

php on windows

Post by kaizix »

i've got php installed (with apache 2.0.39) and it's working (supposedly) because when i make a php page with phpinfo(); in it, i get all the good stuff you're supposed to see. the problem is that i wrote a script and tested on my webhost server (running linux) and the scripts works "perfectly" but when trying to run it on my system, it doesn't do anything it's supposed to do. all running the same versions of php (different apache versions though...would that have to do with it?). i just don't see why it'll work one place and not another.... (actually tried it on two different windows machines and it doesn't work on either but works fine on the linux server...) any suggestions?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What is the script supposed to do? What is the script? Is the PHP configuration exactly the same on all the machines? Does the script use proprietary *nix commands - ie. commands that the manual says work on *nix but not on Windows?

Nobody can really offer any useful suggestions without a lot more information...

Mac
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post by kaizix »

the script basically takes a file and does a search and emails the results. no special commands....hmm code maybe?...

Code: Select all

<?php
// lost_pass.php
// retrieve lost passwords from gm.

if(!isset($action))
   $action = "first";

// function that sends the email.
function find_name($value, $key, $username)
&#123;
 // your email.
 $admin_email = "joe@bob.com";
 
 // get the stuff from that lines of gm-authors.cgi.
 $line = explode("|", $value);
 // if it finds the username, send the mail.
 if(strstr($line&#1111;0], $username))
 &#123;
   // sending the mail out.
   $sent = mail("$line&#1111;2]", "lost password", "you requested your password from http://yoursite.com\n\nusername: $line&#1111;0]\npassword: $line&#1111;1]\n\n", "from: $admin_email");
   if($sent)
    &#123;
       echo "mail has been sent. <a href="http://yoursite.com">back to the site</a>";
     &#125;
 &#125;
&#125;

// function that passes info the function above.
function get_pass($username)
&#123;
  // location of the gm-authors file.
  $author_path = "./cgi-bin/gm-authors.cgi";
  
  // read the file and put the info in an array.
  $author_file = file($author_path);
  
  // how many authors?
  $number = count($author_file);
  
  // see if user is in the file.
  $not_found = 0;
  for($i=0; $i<$number; $i++)
  &#123;
    if(!(strstr($author_file&#1111;$i], $username)))
    &#123;
        $not_found++;
    &#125;
  &#125;
  
  // if author is not found, stop the script and say so.
  if($not_found == $number) die("not found");
  
  // if the author was found, go through the array and send mail.
  array_walk($author_file, 'find_name', $username);
  
&#125;

// get the username from the user.
function form()
&#123;
  ?>
  <html>
  <head>
  <title>get password</title>
  </head>
  <body>
  <form action="<?php echo "$PHP_SELF?action=retrieve"; ?>" method="post">
  name: <input type="text" name="username"><br>
  <input type="submit" name="button" value="get it">
  </form>
  </body>
  </html>
  <?php
&#125;

// decisions, decisions
switch ($action)
&#123;
   case "retrieve":
      get_pass($username);
      break;
   case "first":
      form();
      break;
&#125;
basically what it's doing on the windows machines is displaying the form and then you enter the info (name) and it goes back to the form....as if the switch isn't doing anything. (sorry if my code is junky). and yes the config is the same.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Is register globals perhaps off on some of the machines? Have you tried $_GET['action'] instead of $action?

Mac
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post by kaizix »

yeah, i actually change them to $_POST["blah"] and it seems to be working better....and took out the $PHP_SELF and put in the name of the file....thanks alot... :)
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

You can use $_SERVER['PHP_SELF'] instead of $PHP_SELF .
Post Reply