Script for turning a submitted name into a word!

Discussion in 'PHP' started by Dinvest, Jul 17, 2008.

  1. #1
    Hi,

    I'm looking for a simple free script which could be used on a website where a visitor types in one word and it transforms into another word. Will say, the visitor types in for example "Claire" and the word "beautiful" appears. Of course I should be able to implement in the script what name would turn into what word, but I'm looking for a base code which is already finished and I would only have to type in names and what words should appear when typed in. Nothing fancy at all, just something that works.
    I suppose this script probably would be best in PHP but I'm open for suggestions if you know of a script in another language.
    Please let me know where I could find such a script and I really appreciate you taking your time and helping me find out.

    Thanks in advance!
    Sincerely,
    Dinvest
     
    Dinvest, Jul 17, 2008 IP
  2. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #2
    $words = array('write Dinvest a script' => 'php-lover',
                   'very happy boy' => 'Dinvest',
                   'Hello' => 'world');
    
    $a = 'Dinvest';
    
    if(isset($a)){    //<---change $a to $_POST['word']
    
       if($new_word = array_search($a,$words)){
          
          echo $new_word;
       
       }else{
          
          echo $a;
       
       }
    }
    PHP:
     
    php-lover, Jul 17, 2008 IP
  3. Dinvest

    Dinvest Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Php-lover, I really appreciate you taking your time and writing a script for me!
    It have made me a very happy boy indeed! :)

    I'm not so experienced with PHP scripts, but if I have understood the script correctly it would turn the word "Hello" into "world" , "very happy boy" into "Dinvest" and "write Dinvest a script" into "php-lover". If so it would be no problem for me to modify the script so it would display other words when certain other words are typed in.

    Php-lover, I'm sorry to ask for your time again but what would be the best way to make the script work in a html document? I've called for the php script in a form and with a submit button, but I have not managed to get it to work with the html correctly. I apologize for being such a complete noob :eek:

    Thanks once again!
    Sincerely,
    Dinvest
     
    Dinvest, Jul 18, 2008 IP
  4. scriptglue

    scriptglue Banned

    Messages:
    170
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I made a script that will replace words or phrases when submitted through a form and shows the replaced words on the results page. The word replacements are stored in a txt file

    Example: Type this could you love Claire in the textarea in the demo link below.
    http://scriptglue.com/demos/rewriter/index.php

    The replacements are:
    Claire|beautiful
    love|hate
    could|might
    http://scriptglue.com/demos/rewriter/rel.txt

    Let me know if this is what your looking for.
     
    scriptglue, Jul 18, 2008 IP
  5. Dinvest

    Dinvest Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you Scriptglue! That is exactly the kind of script I'm looking for, thanks for making it for me!

    How could I do to download it?

    Thanks once again, I really appreciate your efforts of making the script for me.
    Sincerely,
    Dinvest
     
    Dinvest, Jul 19, 2008 IP