Jump to content

Robert Elsdon

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Robert Elsdon's Achievements

Member

Member (2/5)

0

Reputation

  1. The form to post messages onto the shoutbox <form action="<? echo $php_self ?>#bottom" method="post"> <center> <? mysql_connect("localhost","root","12345678"); mysql_select_db("shoutbox"); if($_POST['submit']) { ?> <? $name = $_POST['name']; $message= $_POST['message']; $time=date("h:ia d/m/y"); if(!$message) { ?> Please enter a message. <? } else if($message == 'Enter Message') { ?> <font color="#b2eb62"> PLEASE ENTER A MESSAGE</font> <? } else { ?> <? $insertshout="INSERT INTO shoutbox(name,message,time) VALUES ('$name', '$message','$time')"; mysql_query($insertshout) or die("Cannot insert shout"); ?> <script type="text/JavaScript">window.location='index.php';</script> <? } ?> <? } else { } ?> <table> <? if($_SESSION['logged_in'] == 'Yes') { ?> <tr><td> <center>Username :</center> <center><input class="text_input" type='text' value='<?=(ucwords($_SESSION[user_name]));?>' name='name' size=30 maxlength='100' readonly="yes"></center> </td><tr> <? } else { ?> <? } ?> <tr><td> <center>Message :</center> <center><input class="text_input" type="text" maxlength="300" name="message" id="message" value="Enter Message" onclick=document.getElementById('message').value=""; onBlur="shoutmessage();"></center> </td></tr> <tr><td> <center><input class="button" type="submit" name="submit" value="Post Shout" style="margin:0px;"></center> </td></tr> </table> </form> And heres the shoutbox itself which displays the posts <?PHP session_start(); ?> <? include("includes/connect.php"); // Get the messages from the databse $get_messages = mysql_query("select * from shoutbox"); $amountofmessages = mysql_num_rows($get_messages); $select_shouts = mysql_query("select * from shoutbox ORDER BY id DESC LIMIT 10"); ?> <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;"> <? $color='dark'; while($r=mysql_fetch_array($select_shouts)) { if($color == 'dark') { ?> <tr class="dark"> <td><?=$r["time"];?></td> <td><?=$r["date"];?></td> <td><b><font color="#b2eb62"><?=$r["id"];?></font></b> </td> </tr> <tr> <td colspan="3" align="left" style="padding:3px;"> <b><?=$r["name"];?></b><b><font color="#b2eb62"> -</b> </font><?=$r['message'];?> </td> </tr> <? $color='light';} else { ?> <tr class="dark"> <td><?=$r["time"];?></td> <td><?=$r["date"];?></td> <td><b><font color="#b2eb62"><?=$r["id"];?></font></b> </td> </tr> <tr> <td colspan="3" align="left" style="padding:3px;"> <b><?=$r["name"];?></b><b><font color="#b2eb62"> -</b> </font><?=$r['message'];?> </td> </tr> <? $color='dark';} } ?> </table> <? if(!$_SESSION['logged_in'] == 'Yes') { ?> <p align="center"> <font color="#b2eb62">you need to be logged in to view this form to post on shoutbox! </ br> Please, <a href="index.php">Login</a> <b>/</b> <a href="register.php">Register</a> to post a message! </p></font> <? } ?> Regards, Robert
  2. How would i do multiple tags ? heres an example but it doesnt work? You might get what i mean.. <?php $string = "This is a test "; echo str_replace(" ", " <img src='images/smilies/smile.gif'/>", $string); echo str_replace(" ", " <img src='images/smilies/sad.gif'/>", $string); echo str_replace(" ", " <img src='images/smilies/grin.gif'/>", $string); echo str_replace(" ", " <img src='images/smilies/tounge.gif'/>", $string); ?> The last 3 echo str_replace are examples
  3. Yeah it is the shoutbox is in left-nav.php include Is there a script i can add to the shoutbox to replace with image smilie? Thanks, Robert
  4. its for a shoutbox, When you type : ) it replaces with mage automaticly Regards
  5. Now, heres my index page (home page of site). <?PHP session_start();?> <? include("includes/connect.php"); ?> <html> <head> <title> Local Host </title> <link href="includes/style.css" rel="stylesheet" type="text/css"> </head> <div align="center"> <body> <div class="nc_wrapper"> <? include ('includes/header.php'); ?> <div class="spacer"></div> <? include ('includes/left-menu.php'); ?> <div class="content"> <table cellspacing="1" cellpadding="0" border="0" style="width:100%; background:#000000"> <tr><td class="content_head"> Content </td></tr> <tr><td class="actual_content"> Welcome to localhost, This is just a temperary website as for now untill i get it 100% complete! THEN i am giving it to a good friend of mine who owns - <a href="http://pulse-box.com" target="new_window">Pulse-Box</a> so he can sell it to any of yous who like it. :) :) </td></tr> <tr><td class="content_foot"></td></tr> </table> </div> </div> <? include ('includes/footer.php') ?> </div> </body> </html> How would i make it change the in the content with a image by using this script? <?php $string = "This is a test "; echo str_replace(" ", " <img src='images/smilies/smile.gif'/>", $string); ?> Regards Robert
  6. thanks, i had a rough idea lol i was using double quotes thank alot mate i actually learned hehe
  7. Im looking for a little help? <?php $string = "This is be a test"; echo str_replace(" is", " could", $string); ?> where it says could how would i make a image show there?
  8. easy enought for you to say that im a n00b to php please just make me one its easy for you ill learn easier if helped
  9. could you give an example of it? if newish to php and dont no str replace atm thanks
  10. i dont think you got what i ment? i mean like when i type : ) it will automaticly be replaced by <img src="images/smilies/smile.gif"></a> Kind regards Robert
  11. Please help me get a code what will replace : ) with <img src="images/smilies/smile.gif"></a> Regards Robert
  12. i fixed it.. <?PHP session_start(); ?> <? // Your database connection commands mysql_connect("localhost","root","12345678"); mysql_select_db("shoutbox"); if($_POST['submit']) { ?> <? $name = $_POST['name']; $message= $_POST['message']; $time=date("h:ia d/m/y"); $insertshout="INSERT INTO shoutbox(name,message,time) VALUES ('$name', '$message','$time')"; mysql_query($insertshout) or die("Cannot insert shout"); ?> [b]<script type="text/JavaScript">window.location='index.php';</script>[/b] <? } else { } ?> <? // Get the messages from the databse $get_messages = mysql_query("select * from shoutbox"); $amountofmessages = mysql_num_rows($get_messages); $select_shouts = mysql_query("select * from shoutbox ORDER BY id DESC LIMIT 10"); while($r=mysql_fetch_array($select_shouts)) { ?> <?=$r["time"];?> <b><font color="#b2eb62"><?=$r["id"];?></font></b> <br> <b><?=$r["name"];?></b><font color="#b2eb62"> : </font><?=$r['message'];?><br> <? } ?>
  13. hello, i hope yous can help me, Ok what it is, is when i post a comment on my shoutbox, it posts and i can see it, but when i press refresh it posts again, i want to prevent this from happning. any ideas? please help! thanks. <?PHP session_start(); ?> <? // Your database connection commands mysql_connect("localhost","root","12345678"); mysql_select_db("shoutbox"); if($_POST['submit']) { ?> <? $time=date("h:ia d/m/y"); $insertshout="INSERT INTO shoutbox(name,message,time) VALUES ('$name', '$message','$time')"; mysql_query($insertshout) or die("Cannot insert shout"); ?> <? } else { } ?> <? // Get the messages from the databse $get_messages = mysql_query("select * from shoutbox"); $amountofmessages = mysql_num_rows($get_messages); $select_shouts = mysql_query("select * from shoutbox ORDER BY id DESC LIMIT 10"); while($r=mysql_fetch_array($select_shouts)) { ?> <font color="#b2eb62"><?=$r["time"];?></font> <b><font color="#b2eb62"><?=$r["id"];?></font></b> <br> <b><i><?=$r["name"];?></i></b><font color="#b2eb62"> : </font><?=$r['message'];?><br> <? } ?>
  14. did it myself <form action="populate.php?url=<?php echo $_GET ['url'] ?>" method="post" name="url"> Name: <input type="text" name="url" /> <input type='submit' value='Submit URL'> </form> i chnaged <?php echo $_POST['url'] ?> to <?php echo $_GET ['url'] ?> Thanks for the help SOLVED!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.