foevah Posted November 8, 2007 Share Posted November 8, 2007 Hi everyone I have built a php blog from a basic tutorial and it doesnt tell me how I can post a link with my blog entires. If I type www.phpfreaks.com it won't let the user click on the link. Please can someone help me add this function to my blog form? Below I will show you the code I have in my blog entry form and the view blog entries page. This is my blog form code: <?php $current_month = date("F"); $current_date = date("d"); $current_year = date("Y"); $current_time = date("H:i"); if (isset($_POST['submit'])) { $month = htmlspecialchars(strip_tags($_POST['month'])); $date = htmlspecialchars(strip_tags($_POST['date'])); $year = htmlspecialchars(strip_tags($_POST['year'])); $time = htmlspecialchars(strip_tags($_POST['time'])); $title = htmlspecialchars(strip_tags($_POST['title'])); $image = htmlspecialchars(strip_tags($_POST['image'])); $entry = $_POST['entry']; $password = htmlspecialchars(strip_tags($_POST['password'])); $entry = nl2br($entry); //checking for emptys if (strlen($_POST['title'])>0 && strlen($_POST['title'])<255 && strlen($_POST['entry'])>0 && strlen($_POST['entry'])<4000000000) { $title = (!get_magic_quotes_gpc()) ? mysql_real_escape_string($_POST['title']): $_POST['title']; $entry = (!get_magic_quotes_gpc()) ? mysql_real_escape_string($_POST['entry']): $_POST['entry']; $timestamp = $current_time; include "connect.php"; $password = (isset($_POST['password']))? 1:0; @mysql_connect($server, $connect, $pass) or die(__LINE__. mysql_error()); @mysql_select_db($database) or die(__LINE__. mysql_error()); //If the Submitbutton was pressed do: $uploaddir="./blog_images"; $filename = $_FILES['imagefile']['name']; $filename = renfilename($filename,$uploaddir); if ($filename != "") { chdir($uploaddir); if (preg_match('/(\.jpg)$/i', $filename)) { if (!file_exists($filename)) { if (move_uploaded_file($_FILES['imagefile']['tmp_name'], $filename)) { chmod($filename, 0755); $new_name = preg_replace('/_big/','_small',$filename); $sql = "INSERT INTO `php_blog` (`timestamp`,`title`,`entry`,`password`,`image`) VALUES (NOW(), '$title','$entry','$password','$new_name')"; $result = mysql_query($sql) or print("Can't insert into table php_blog.<br />" . $sql . "<br />" . mysql_error()); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Blog entry form</title> <script type="text/javascript"> function addsmiley(string) { var newtext = string; document.addthread.entry.value += newtext; document.addthread.entry.focus(); return; } </script></head> <head> <form name="addthread" method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>" enctype="multipart/form-data"> <p><strong><label for="month">Date (month, day, year):</label></strong> <select name="month" id="month"> <option value="<?php echo "$current_month"; ?>"><?php echo "$current_month"; ?></option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="text" name="date" id="date" size="2" value="<?php echo $current_date; ?>" /> <select name="year" id="year"> <option value="<?php echo $current_year; ?>"><?php echo $current_year; ?></option> <option value="2004">2004</option> <option value="2005">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2008</option> <option value="2010">2010</option> </select> <strong><label for="time">Time:</label></strong> <input type="text" name="time" id="time" size="5" value="<?php echo $current_time; ?>" /></p> <p><strong><label for="title">Title:</label></strong> <input type="text" name="title" name="title" size="40" /></p> <img src="../images/smileg.gif" width="15" height="15" onClick="addsmiley('')"> <img src="../images/wink.gif" width="15" height="15" onClick="addsmiley('')"> <img src="../images/bold.gif" onClick="addsmiley('[b][/b]')"> <img src="../images/italic.gif" onClick="addsmiley('[i][/i]')"> <p><strong><label for="password">Password protect?</label></strong><input type="checkbox" name="password" id="password" value="1" /></p> <p><textarea name="entry" cols="80" rows="20" id="entry"></textarea></p> <input type="file" name="imagefile"> <input type="submit" name="submit" value="Save"> </form> </head> </html> This is my view blog entry code: <?php include "connect.php"; @ mysql_connect($server, $connect, $pass) or die(__LINE__. mysql_error()); @ mysql_select_db($database) or die(__LINE__. mysql_error()); function smiley($content) { $find[] = ""; $replace[] = "<img src='../jecgardner/images/smileg.gif' alt='smile'/>"; $find[] = ""; //NEW SMILEY SEARCH $replace[] = "<img src='../jecgardner/images/wink_b.gif' alt='wink'/>";//NEW SMILEY REPLACE $find[] = "[b]"; //Look for bold tag $replace[] = "<span style='font-weight: bold;'>"; //Replace with span tag $find[] = "[/b]"; //Look for bold end tag $find[] = "[.code]"; //Look for code tag $replace[] = "<span style='background-color:#646464; color: white;'>"; //Replace with span tag $find[] = " [./code]"; //Look for code end tag $replace[] = "</span>"; //replace with end span echo str_replace($find, $replace, $content);//This always needs to be at the end of the function } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>James Gardner: Web Designer</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="title" content="James Gardner's university website" /> <script type="text/javascript" src="tooltip.js"></script> <link href="css/main.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main_text"> <?php function showinweb($val) { $val = nl2br($val); //return returns the value and ends execution of function, so any line below it is ignored return($val); } $page = (!isset($_GET['page'])) ? 1: $_GET['page']; // Define the number of results per page $max_results = 3; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); // Perform MySQL query on only the current page number's results $sql = "SELECT id, DATE_FORMAT(timestamp, '%a.%b.%y') as dateAdded, title, entry, password, image FROM php_blog ORDER BY timestamp DESC LIMIT $from, $max_results"; $result = mysql_query($sql) or print ("Can't select entries from table php_blog.<br />" . $sql . "<br />" . mysql_error()); $i =1; while($row = mysql_fetch_assoc($result)) { echo "<div class='box1'>"; echo "<p class='blogtitle'> <span class='blogtit'>".showinweb($row['title'])."</span></p><br />"; echo "<br /><br />".smiley(showinweb($row['entry'])); echo "<img src=\"entry/blog_images/".showinweb($row['image'])."\" alt=\"\" class=\"thumb\"/>"; echo "<br />".showinweb($row['dateAdded']); } ?> </div> </body> </html> EDITED BY WILDTEEN88: Please use code tags ( ) Quote Link to comment Share on other sites More sharing options...
trq Posted November 8, 2007 Share Posted November 8, 2007 Search the board for bbcode[/url], should help you out. Quote Link to comment Share on other sites More sharing options...
foevah Posted November 8, 2007 Author Share Posted November 8, 2007 ok so i searched for bbcode and only my thread came up :-\ Quote Link to comment Share on other sites More sharing options...
trq Posted November 8, 2007 Share Posted November 8, 2007 I get 15 pages of results. Quote Link to comment Share on other sites More sharing options...
foevah Posted November 10, 2007 Author Share Posted November 10, 2007 no joke only this thread comes up Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted November 10, 2007 Share Posted November 10, 2007 http://www.phpfreaks.com/tutorials/141/0.php 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.