Results 1 to 5 of 5

Thread: Insert text to be displayed on site

  1. #1
    Join Date
    Aug 2008
    Location
    North Wales
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Insert text to be displayed on site

    Firstly, Hi everyone. As you can probably see, I'm new and no good at coding myself. I have used Dynamic Drive cos they have some pretty neat stuff.

    My question is, is there any way a visitor on my site could type his/her name in a text input box, hit enter, and it comes up at the top of the page saying "Hello! name" Personalizing the header.

    I know it sounds a daft question (or it is worded wrong) but thanks in advance.
    Last edited by jamesh_1993; 08-04-2008 at 09:20 PM. Reason: rewording

  2. #2
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    I know it can be done with a "shell" script. I'm sure it can probably be accomplished via Javascript and/or PHP as well... Here is a link to check out.

    http://bash.cyberciti.biz/academic/ask-user-name/
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  3. #3
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Here's a Javascript counterpart:
    Code:
    <script type="text/javascript">
    window.onload=function(){
    document.getElementById('enter').onclick=function(){
    document.getElementById('show').innerHTML='Hello <span style="color:#930;">'+document.getElementById('urName').value+'</span> Welcome!';}}
    </script>
    <div id="show" style="font-family:Arial,helvetica,serif;font-size:15pt;"></div>
    <label for="urName">Name: </label><input type="text" id="urName">
    <input type="button" value="Enter" id="enter">
    and a PHP one:
    PHP Code:
    <?php
    if(ISSET($_POST['urName']))
    echo 
    '<div id="show" style="font-family:Arial,helvetica,serif;font-size:15pt;">Hello <span style="color:#930;">'.$_POST['urName'].'</span> Welcome!</div>';
    ?>
    <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
    <label for="urName">Name: </label><input type="text" id="urName" name="urName">
    <input type="submit" value="Enter">
    </form>
    Hope this gives you a variety of choices.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  4. #4
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    Now if we could just figure out a way to give them an HTML version... They'd be all set! lol
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  5. #5
    Join Date
    Aug 2008
    Location
    North Wales
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    Quote Originally Posted by rangana View Post
    Here's a Javascript counterpart:
    Code:
    <script type="text/javascript">
    window.onload=function(){
    document.getElementById('enter').onclick=function(){
    document.getElementById('show').innerHTML='Hello <span style="color:#930;">'+document.getElementById('urName').value+'</span> Welcome!';}}
    </script>
    <div id="show" style="font-family:Arial,helvetica,serif;font-size:15pt;"></div>
    <label for="urName">Name: </label><input type="text" id="urName">
    <input type="button" value="Enter" id="enter">
    and a PHP one:
    PHP Code:
    <?php
    if(ISSET($_POST['urName']))
    echo 
    '<div id="show" style="font-family:Arial,helvetica,serif;font-size:15pt;">Hello <span style="color:#930;">'.$_POST['urName'].'</span> Welcome!</div>';
    ?>
    <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
    <label for="urName">Name: </label><input type="text" id="urName" name="urName">
    <input type="submit" value="Enter">
    </form>
    Hope this gives you a variety of choices.
    Thanks for that. I'm not great with coding and stuff, so i just put this under the HTML Thread.

    (Y)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •