php help

Discussion in 'PHP' started by kumar84, Sep 28, 2007.

  1. #1
    hai friends

    if i execute the below code means, Iam able to get the result stored in fname and the second time if i enter the value it is replacing the old value
    Now what i need is
    for the first time if i enter the value as x, it should display as x
    for the second time if i enter the value as y it should display as xY
    for the third time if i enter the value as z it should display as xyz
    ................

    for this scenario what i need to change in the below code, any body help me


    file name: time.php



    <?php
    if(isset($_POST["sub"])){
    $display=$_POST["fname"];
    echo $display;
    }
    ?>
    <form method="post" action="time.php">
    <input type="text" name="fname">
    <input type="submit" name="sub" value="submit">
    </form>


    Thanks for ur help in advance
     
    kumar84, Sep 28, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    <?php
    
    if (isset($_POST["sub"]))
    {
    	$temp = htmlspecialchars($_POST['temp'] . $_POST['fname']);
    	echo $temp;
    }
    
    ?>
    <form method="post" action="time.php">
    <input type="text" name="fname">
    <input type="submit" name="sub" value="submit">
    <input type="hidden" value="<?php echo isset($temp) ? $temp : ''; ?>" name="temp" />
    </form>
    
    
    PHP:
     
    nico_swd, Sep 28, 2007 IP