+ Reply to Thread
Results 1 to 7 of 7

Thread: Shout Box

  1. #1
    richm8026 is offline x10 Sophmore richm8026 is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    138

    Shout Box

    I am going to insert some HTML Codes, can anybody here help with the PHP Scripts?

    Code:
    <table style="width: 40%; background-color: #FFF" align="right">
    
    <tr>
    
    <td valign="top">
    
    <p class="style1">Shout Box</p>
    
    <form method="post" action="">
    
    <p>UserName: <input type="text" id="username" value="Guest and/or username" /></p>
    <p>Message:<input type="text" id="message" value="Your Message Here" /></p> <br />
    <p><input type="submit" id="submit" value="Submit" size="10" /></p>
    
    <textarea wrap="soft" readonly="readonly" id="text">
    
    </textarea>
    
    </form>
    
    
    </td>
    
    </tr>
    
    </table>
    Thanks for the help


  2. #2
    quantum1's Avatar
    quantum1 is offline x10Hosting Member quantum1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    near Nashville, TN
    Posts
    68

    Re: Shout Box

    <?php
    // define function that will output text with dos newlines so that view
    // source will show human readable html; f_say will be used in place of
    // php echo statement when generating html
    function f_say($text)
    {
    echo $text."\r\n";
    }

    f_say("<table style=\"width: 40%; background-color: #FFF\" align=\"right\">");
    f_say("<tr>");
    f_say("<td valign=\"top\">");
    f_say("<p class=\"style1\">Shout Box</p>");
    f_say("<form method=\"post\" action=\"\">");
    f_say("<p>UserName: <input type=\"text\" id=\"username\" value=\"Guest and/or username\" /></p>");
    f_say("<p>Message:<input type=\"text\" id=\"message\" value=\"Your Message Here\" /></p> <br />");
    f_say("<p><input type=\"submit\" id=\"submit\" value=\"Submit\" size=\"10\" /></p>");
    f_say("<textarea wrap=\"soft\" readonly=\"readonly\" id=\"text\">");
    f_say("</textarea>");
    f_say("</form>");
    f_say("</td>");
    f_say("</tr>");
    f_say("</table>");
    ?>
    Two rules of development:
    1) Computers work for people; People do not work for computers
    2) Maintainability is all that matters.

  3. #3
    richm8026 is offline x10 Sophmore richm8026 is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    138

    Re: Shout Box

    Hmm, I must have goofed up, it didn't work

    am I supposed to put the table stuff f_say in the <body> </body> sections?
    Last edited by richm8026; 12-02-2008 at 01:16 PM.


  4. #4
    quantum1's Avatar
    quantum1 is offline x10Hosting Member quantum1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    near Nashville, TN
    Posts
    68

    Re: Shout Box

    No problem. The double quotes that are actually part of you HTML are escaped with a backslash to indicate that we actually want to output a double quote character. If you use single quotes in your HTML you would not have to escape them. However, variable handling in PHP is different inside double quotes versus single quotes. If you are new to PHP and are not using PHP variables yet as part of building your HTML (that is, you are just using PHP to create straight non-changing HTML output) then I would use single quotes. That way it would look like below, without the need for escape backslashes:

    <?php
    // define function that will output text with dos newlines so that view
    // source will show human readable html; f_say will be used in place of
    // php echo statement when generating html
    function f_say($text)
    {
    echo $text."\r\n";
    }

    f_say("<table style='width: 40%; background-color: #FFF' align='right'>");
    f_say("<tr>");
    f_say("<td valign='top'>");
    f_say("<p class='style1'>Shout Box</p>");
    f_say("<form method='post' action=''>");
    f_say("<p>UserName: <input type='text' id='username' value='Guest and/or username' /></p>");
    f_say("<p>Message:<input type='text' id='message' value='Your Message Here' /></p> <br />");
    f_say("<p><input type='submit' id='submit' value='Submit' size='10' /></p>");
    f_say("<textarea wrap='soft' readonly='readonly' id='text'>");
    f_say("</textarea>");
    f_say("</form>");
    f_say("</td>");
    f_say("</tr>");
    f_say("</table>");
    ?>
    Two rules of development:
    1) Computers work for people; People do not work for computers
    2) Maintainability is all that matters.

  5. #5
    richm8026 is offline x10 Sophmore richm8026 is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    138

    Re: Shout Box

    Thanks, it didn't work, maybe I can just use JavaScript for that, not sure if I can though, I do want it to save all of the messages that way people who sign on later that day can see what everybody has said, I would have to write to a file I guess, so, I would have to use PHP, I'll learn it eventually, and yes, I am new to PHP, I am not sure if I keep the PHP Scripts above the <!doctype> or not, or if I am supposed to keep the echo part in there, or move that part between the <textarea> area.... So, for now, I'll just work on the rest of the site. Thanks for your time.. :-)


  6. #6
    quantum1's Avatar
    quantum1 is offline x10Hosting Member quantum1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    near Nashville, TN
    Posts
    68

    Re: Shout Box

    Sorry! I responded without reading your post about it not working. You can use PHP anywhere in your HTML. Instead of creating a *.HTM or *.HTML file extension create a *.PHP file extension and then you can put plain HTML or a mixture of HTML and PHP or just straight PHP in that file. It's just that you create the HTML output using the PHP echo command (or in my case a function that then uses echo). You would then point your browser to myfile.php and the server would run php against your file. At that time the PHP program would generate the HTML to go back to the browser. Since PHP is in charge in a PHP scenario, you can use PHP to "echo" back to the browser the HTML needed for your web page. You can visit www.w3schools.com to get free training and information on HTML, PHP, Javascript and much more. They have examples that will probably answer your questions. PHP allows you to generate dynamic HTML, that is, you can build HTML on the fly that changes as you need it to. The browser will get just HTML (or HTML with javascript, depending on what your generate with your PHP).
    Two rules of development:
    1) Computers work for people; People do not work for computers
    2) Maintainability is all that matters.

  7. #7
    infurTH is offline x10Hosting Member infurTH is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    44

    Re: Shout Box

    you have to create a .php extension

+ Reply to Thread

Similar Threads

  1. shout box and bandwidth uses
    By gomcodoctor in forum Free Hosting
    Replies: 3
    Last Post: 07-24-2008, 10:41 PM
  2. Flash Shout Box for 500 Credits.
    By satheesh in forum The Marketplace
    Replies: 7
    Last Post: 10-20-2007, 08:28 AM
  3. ShoutCast Song Request & Shout Out
    By TheJeffsta in forum Scripts & 3rd Party Apps
    Replies: 7
    Last Post: 05-18-2006, 04:13 PM
  4. is my account shout down
    By mumia in forum Free Hosting
    Replies: 6
    Last Post: 09-19-2005, 08:28 AM
  5. Be Nive to have a lil shout box in Here
    By badboy740 in forum Feedback and Suggestions
    Replies: 7
    Last Post: 05-26-2005, 07:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers