Robert Elsdon
Members-
Posts
45 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Robert Elsdon's Achievements
Member (2/5)
0
Reputation
-
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
-
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
-
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
-
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> <? } ?>
-
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> <? } ?>
-
[SOLVED] How to do this form? L@@K please!!
Robert Elsdon replied to Robert Elsdon's topic in PHP Coding Help
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!