BigJohnny Posted June 15, 2008 Share Posted June 15, 2008 Ok, so first of all, I don't know php.... I have only the slightest grasp of things, But I think this is a simple problem. I've downloaded a shoutbox to put on my website, and taken my index.html file, renamed it to index.php and used a php include, to include the shoutbox on my page. This website is also a template I downloaded somewhere. I'm just trying to get a simple site put up fairly quickly. this will Sound confusing, so you can see what im talking about here www.teamspeakdisplay.com (Username: user Password: tdisplay) First problem, using index.php being that its html, it doesn't seem to fully load the style.css file, and throws my menu out of whack. index2.html will show you how the menu is supposed to look. second problem, the shoutbox seems to load ok, except it uses an iframe to display the actual shouts. For some reason the shoutbox iframe is loading my webpage inside of it, and then its displaying the shouts, in the shoutboxes iframe, on the website inside the iframe. Also, the form for "shouting" doesnt line up properly. The texta area and the name/website fields arent the same length, and i cant seem to get them to align. And lastly, Is it possible to take out the style info in the PHP file, and put it into my main style.css file instead? Here is the code for the shoutbox PHP file. <?php //------ Edit Below This Line ------// define('SHOUTBOX', 'shoutbox'); $host = 'localhost'; $dbuser = 'USERNAME'; // Username to access database. $dbpass = 'PASSWORD'; // Password to access database. $dbname = 'DBNAME'; // Database name. $allowed_tags = '<b><i><u><a>'; //------ Edit Above This Line ------// mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); function clean_string($string, $tags = '') { $string = trim($string); $string = str_replace("\'", "''", $string); return $string; } ?> <style type="text/css"> .shoutbox { margin: 0px; padding: 0px; background-color: FFFFFF} .shoutbox a, a:visited { color: 6E7A8A; font-size: 12px; font-weight: bold; text-decoration: none;} .shoutbox a:hover { color: 6E7A8A; text-decoration: underline; } .shoutbox input, select, textarea { border: 1px solid silver;} .form { font-size: 12px;} #name1 { background-color: E0E0E0; color: 666666; font-size: 12px;} #content1 { background-color: E0E0E0; font-size: 12px;} #name2 { background-color: F3F3F3; color: 666666; font-size: 12px;} #content2 { background-color: F3F3F3; font-size: 12px;} </style> <?php switch($_GET['p']) { case 'box': echo "<body class=\"shoutbox\">\n<table cellpadding=\"0\">"; $result = mysql_query("SELECT * FROM " . SHOUTBOX . " ORDER BY id DESC") or die(mysql_error()); for ($i = 1; $i <= ($row = mysql_fetch_assoc($result)); $i++) { $nameid = (!($i % 2)) ? 'name1' : 'name2'; $contentid = (!($i % 2)) ? 'content1' : 'content2'; $name = strip_tags(stripslashes($row['name']), $allowed_tags); $website = strip_tags(stripslashes($row['website']), $allowed_tags); $content = strip_tags(stripslashes($row['content']), $allowed_tags); echo '<tr><td id="' . $nameid . '" width="50" align="right">', // This line controls the width of the name column. ((!empty($row['website'])) ? "<a href=\"$website\">$name</a>" : $name), '</td><td id="' . $contentid . '" width="340">' . $content . "</td></tr>\n"; // This line controls the width of the shout.. } echo "</table>\n</body>"; break; default: echo '<div class="shoutbox">'; if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['name']) && !empty($_POST['content'])) { $name = clean_string($_POST['name']); $website = clean_string($_POST['website']); $website = (!empty($website) && $website != 'http://') ? (!eregi('^http://', $website) ? 'http://' . $website : $website) : ''; $content = nl2br(clean_string($_POST['content'], '<a>')); mysql_query("INSERT INTO " . SHOUTBOX . " (name, website, content) VALUES ('$name', '$website', '$content')") or die(mysql_error()); } // THIS IS THE SPOT I CANT GET TO ALIGN PROPERLY echo '<iframe src="' . basename($_SERVER['PHP_SELF']) . '?p=box" width="348" height="75"></iframe> <form method="post"><table class="form"> <tr><td><input type="text" name="name" size="52" value="Name"></td></tr> <tr><td><input type="text" name="website" value="http://" size="52"></td></tr> <tr><td><textarea name="content" rows="3" cols="40" value="Message"></textarea></td></tr> <tr><td colspan="2" align="center" style="width:100px;"><input type="submit" value="Submit"></td></tr> </table></form>', "\n</div>"; //break; } /* Run the below query in phpMyAdmin, under the shoutbox database, to create the tables. CREATE TABLE shoutbox ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(50), website VARCHAR(150), content VARCHAR(255), PRIMARY KEY (id) ); */ ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.