problems arise from upgrading php

Discussion in 'PHP' started by tikitin, Aug 13, 2008.

  1. #1
    The scripts which were written for php 4.3.0 do not seem to work with php 5.1.2
    Or did I forget something when I configured php 5.1.2?

    With php 4.3.0 writing something in the password field produces whatever I wrote and "OK", but with 5.1.2 the variable does not pass.

    <?php
    echo $var.<br>;

    if (!$var){
    echo "<form name=login method=post action='test.php'>"; echo "<input type=password name=var>";
    echo "<br><input type=submit value='click'>";
    echo "</form>";
    }
    else{
    echo "OK";
    }

    ?>
     
    tikitin, Aug 13, 2008 IP
  2. nfd2005

    nfd2005 Well-Known Member

    Messages:
    295
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    130
    #2
    $var=$_POST['var'];
    PHP:
     
    nfd2005, Aug 13, 2008 IP
  3. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    you can do something like this
    
    <?
    
    if(isset($_POST['submit'])) {
    
    $var = $_POST[var];
    
    echo "OK";
    } else {
    echo 'Your html form';
    }
    ?>
    
    
    PHP:
     
    CarcaBot, Aug 13, 2008 IP
  4. whoispark

    whoispark Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Use this :-

    <?
    	if(isset($_POST['click']))
    	{
    		echo $_POST['var'];
    		exit;
    	}
    	else
    	{
    		echo "OK";
    	}
    
    	echo "<form name='login' method='post' action='test.php'>"; 
    		echo "<input type='password' name='var'>";
    		echo "<br><input type='submit' value='click' name='click'>";
    	echo "</form>";
    ?>
    PHP:
     
    whoispark, Aug 13, 2008 IP
  5. whoispark

    whoispark Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Also, there are quite a few changes implied in the change from PHP4 to PHP5. Have a look at the PHP manual.
     
    whoispark, Aug 13, 2008 IP
  6. tikitin

    tikitin Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you, this problem was solved.
    But I could not find any mention of this in the PHP manual in the chapter which dealt with changes in migrating from 4 to 5.

    Now I) ran into something else (which wasn't mentioned in the manual, either). This is about error messages.

    If I write a script with a mistake in it (an extra parenthesis),

    <?php
    echo "This is a php-script";
    {
    ?>

    PHP 4 gives an error message:
    Parse error: parse error, unexpected $ in /server/apache/htdocs/errormessage.php on line 3

    PHP 5 returns a blank page. This is quite inconvenient, when trying to locate something extra or someting missing in a 300 line script.
     
    tikitin, Aug 17, 2008 IP