Jump to content

foevah

Members
  • Posts

    162
  • Joined

  • Last visited

    Never

Everything posted by foevah

  1. I am trying to get mathguard to work to stop bots from using my form. This is what my form looks like: http://www.newmedia.lincoln.ac.uk/jecgardner/entry/journal.php?id=5 If i fill in all the options except the maths question the comment still submits. The point of having this maths question is so if the user/bot cant figure out the answer then the comment wont submit. Please can someone tell me why the comment still submits? This form works with 3 pages 1. comments page (journal.php) 2. process.php 3. ClassMathGuard.php - i am trying to link the three... If the user doesnt enter an email with the @ sign then the comment won't submit so this validation works. I just cant get the mathguard to work!?!?!? Please help! Comment form: <form method="post" action="../process.php" name="book" > <p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>"> <strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="25" /><br /> <strong><label for="email">E-mail:</label></strong> <input type="text" name="email" id="email" size="25" /><br /> <strong><label for="url">URL:</label></strong> <input type="text" name="url" id="url" size="25" value="http://" /><br /> <strong><label for="comment">Comment:</label></strong><br /> <textarea cols="25" rows="5" name="comment" id="comment"></textarea></p> <? require("ClassMathGuard.php"); MathGuard::insertQuestion(); ?> <input type='hidden' name='action' value='submit'/> <p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" class="input" onclick="nospam();"/> </p> </form> process.php: <? /* first we need to require our MathGuard class */ require ("ClassMathGuard.php"); /* this condition checks the user input. Don't change the condition, just the body within the curly braces */ if (MathGuard :: checkResult($_REQUEST['mathguard_answer'], $_REQUEST['mathguard_code'])) { echo ("Great !"); //insert your code that will be executed when user enters the correct answer } else { echo ("Bad answer, go back to school !"); //insert your code which tells the user he is spamming your website die(); } ?> <?php if (isset($_POST['submit_comment'])) { if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comment'])) { die("You have forgotten to fill in one of the required fields! Please make sure you submit a name, e-mail address and comment."); } $entry = htmlspecialchars(strip_tags($_POST['entry'])); $timestamp = htmlspecialchars(strip_tags($_POST['timestamp'])); $name = htmlspecialchars(strip_tags($_POST['name'])); $email = htmlspecialchars(strip_tags($_POST['email'])); $url = htmlspecialchars(strip_tags($_POST['url'])); $comment = htmlspecialchars(strip_tags($_POST['comment'])); $comment = nl2br($comment); if (!get_magic_quotes_gpc()) { $name = addslashes($name); $url = addslashes($url); $comment = addslashes($comment); } if (!eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) { die("The e-mail address you submitted does not appear to be valid. Please go back and correct it."); } include "connect.php"; @ mysql_connect($server, $connect, $pass) or die(__LINE__. mysql_error()); @ mysql_select_db($database) or die(__LINE__. mysql_error()); $result = mysql_query("INSERT INTO php_blog_comments (entry, timestamp, name, email, url, comment) VALUES ('$entry','$timestamp','$name','$email','$url','$comment')"); header("Location: entry/journal.php?id=" . $entry); } else { die("Error: you cannot access this page directly."); } ?> ClassMathGuard.php: <? class MathGuard { /** A main hashing function: concat of user's answer, hour and the additional prime number (default 37) */ function encode($input, $prime) { return md5($input.date("H").$prime); } /** This function generates the hash code from the two numbers * @param $a first number * @param $b second sumber * @param $prime additional number to encode with * */ function generateCode($a, $b, $prime) { $code = MathGuard::encode($a + $b, $prime); return $code; } /** This function checks whether the answer and generated security code match * @param $mathguard_answer answer the user has entered * @param $mathguard_code hashcode the mathguard has generated */ function checkResult($mathguard_answer, $mathguard_code, $prime = 37) { // echo("prime; $prime, $mathguard_answer"); $result_encoded = MathGuard::encode($mathguard_answer, $prime); if ($result_encoded == $mathguard_code) return true; else return false; } /** this function inserts the two math term into your form, the parameter is optional */ function insertQuestion($prime = 37) { //default prime is 37, you can change it when specifying the different parameter $a = rand() % 10; // generates the random number $b = rand() % 10; // generates the random number $code = MathGuard :: generateCode($a, $b, $prime); echo ("<a href='http://www.codegravity.com/projects/mathguard'>MathGuard</a> security question: $a + $b = <input type='input' name='mathguard_answer' size='2'/><input type='hidden' name='mathguard_code' value='$code' />"); } /** this function returns math expression into your form, the parameter is optional * quite simmilar to insertQuestion, but returns the output as a text instead of echoing */ function returnQuestion($prime = 37) { //default prime is 37, you can change it when specifying the different parameter $a = rand() % 10; // generates the random number $b = rand() % 10; // generates the random number $code = MathGuard :: generateCode($a, $b, $prime); return ("<a href='http://www.codegravity.com/projects/mathguard'>MathGuard</a> security question: $a + $b = <input type='input' name='mathguard_answer' size='2'/><input type='hidden' name='mathguard_code' value='$code' />"); } } ?>
  2. I am trying to get mathguard to work to stop bots from using my form. This is what my form looks like: http://www.newmedia.lincoln.ac.uk/jecgardner/entry/journal.php?id=5 If i fill in all the options except the maths question the comment still submits. The point of having this maths question is so if the user/bot cant figure out the answer then the comment wont submit. Please can someone tell me why the comment still submits? This form works with 3 pages 1. comments page (journal.php) 2. process.php 3. ClassMathGuard.php - i am trying to link the three... If the user doesnt enter an email with the @ sign then the comment won't submit so this validation works. I just cant get the mathguard to work!?!?!? Please help! Comment form: <form method="post" action="../process.php" name="book" > <p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>"> <strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="25" /><br /> <strong><label for="email">E-mail:</label></strong> <input type="text" name="email" id="email" size="25" /><br /> <strong><label for="url">URL:</label></strong> <input type="text" name="url" id="url" size="25" value="http://" /><br /> <strong><label for="comment">Comment:</label></strong><br /> <textarea cols="25" rows="5" name="comment" id="comment"></textarea></p> <? require("ClassMathGuard.php"); MathGuard::insertQuestion(); ?> <input type='hidden' name='action' value='submit'/> <p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" class="input" onclick="nospam();"/> </p> </form> process.php: <? /* first we need to require our MathGuard class */ require ("ClassMathGuard.php"); /* this condition checks the user input. Don't change the condition, just the body within the curly braces */ if (MathGuard :: checkResult($_REQUEST['mathguard_answer'], $_REQUEST['mathguard_code'])) { echo ("Great !"); //insert your code that will be executed when user enters the correct answer } else { echo ("Bad answer, go back to school !"); //insert your code which tells the user he is spamming your website die(); } ?> <?php if (isset($_POST['submit_comment'])) { if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comment'])) { die("You have forgotten to fill in one of the required fields! Please make sure you submit a name, e-mail address and comment."); } $entry = htmlspecialchars(strip_tags($_POST['entry'])); $timestamp = htmlspecialchars(strip_tags($_POST['timestamp'])); $name = htmlspecialchars(strip_tags($_POST['name'])); $email = htmlspecialchars(strip_tags($_POST['email'])); $url = htmlspecialchars(strip_tags($_POST['url'])); $comment = htmlspecialchars(strip_tags($_POST['comment'])); $comment = nl2br($comment); if (!get_magic_quotes_gpc()) { $name = addslashes($name); $url = addslashes($url); $comment = addslashes($comment); } if (!eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) { die("The e-mail address you submitted does not appear to be valid. Please go back and correct it."); } include "connect.php"; @ mysql_connect($server, $connect, $pass) or die(__LINE__. mysql_error()); @ mysql_select_db($database) or die(__LINE__. mysql_error()); $result = mysql_query("INSERT INTO php_blog_comments (entry, timestamp, name, email, url, comment) VALUES ('$entry','$timestamp','$name','$email','$url','$comment')"); header("Location: entry/journal.php?id=" . $entry); } else { die("Error: you cannot access this page directly."); } ?> ClassMathGuard.php: <? class MathGuard { /** A main hashing function: concat of user's answer, hour and the additional prime number (default 37) */ function encode($input, $prime) { return md5($input.date("H").$prime); } /** This function generates the hash code from the two numbers * @param $a first number * @param $b second sumber * @param $prime additional number to encode with * */ function generateCode($a, $b, $prime) { $code = MathGuard::encode($a + $b, $prime); return $code; } /** This function checks whether the answer and generated security code match * @param $mathguard_answer answer the user has entered * @param $mathguard_code hashcode the mathguard has generated */ function checkResult($mathguard_answer, $mathguard_code, $prime = 37) { // echo("prime; $prime, $mathguard_answer"); $result_encoded = MathGuard::encode($mathguard_answer, $prime); if ($result_encoded == $mathguard_code) return true; else return false; } /** this function inserts the two math term into your form, the parameter is optional */ function insertQuestion($prime = 37) { //default prime is 37, you can change it when specifying the different parameter $a = rand() % 10; // generates the random number $b = rand() % 10; // generates the random number $code = MathGuard :: generateCode($a, $b, $prime); echo ("<a href='http://www.codegravity.com/projects/mathguard'>MathGuard</a> security question: $a + $b = <input type='input' name='mathguard_answer' size='2'/><input type='hidden' name='mathguard_code' value='$code' />"); } /** this function returns math expression into your form, the parameter is optional * quite simmilar to insertQuestion, but returns the output as a text instead of echoing */ function returnQuestion($prime = 37) { //default prime is 37, you can change it when specifying the different parameter $a = rand() % 10; // generates the random number $b = rand() % 10; // generates the random number $code = MathGuard :: generateCode($a, $b, $prime); return ("<a href='http://www.codegravity.com/projects/mathguard'>MathGuard</a> security question: $a + $b = <input type='input' name='mathguard_answer' size='2'/><input type='hidden' name='mathguard_code' value='$code' />"); } } ?>
  3. Azu - I didnt ignore it I am just juggling options right now. I am not sure how to approve comments. How can I do this? I would like to speak to GuiltyGear and see if he knows why his captcha isnt working yet..
  4. I dont know how to install an approval system. I dont know if i have installed this JS right? I know for a fact i havent installed this captcha correctly because when i submit a page with incorrect digits it still posts the comment I would like to get this working. I dont know what i am doing wrong
  5. k i think i applied this JS technique correctly but someone/something is still leaving irrelevant comments! They always say "thank you good site" with a stupid url linking to rubbish! This is a comments page on my site: http://www.newmedia.lincoln.ac.uk/jecgardner/entry/journal.php?id=4 There supposed to be 2 comments one from Igor and the other from webnoob but there is a stranger that keeps coming back and i have to delete there comments!!! This is my form now which looks right to me! <form method="post" action="../process.php" name="book" enctype="multipart/form-data" onsubmit="return checkForm()"> <p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>"> <strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="25" /><br /> <strong><label for="email">E-mail:</label></strong> <input type="text" name="email" id="email" size="25" /><br /> <strong><label for="url">URL:</label></strong> <input type="text" name="url" id="url" size="25" value="http://" /><br /> <strong><label for="comment">Comment:</label></strong><br /> <textarea cols="25" rows="5" name="comment" id="comment"></textarea></p> <img src="captcha.php" /> <input type="text" name="captchacode" id="captchacode" size="15" /> <input type="hidden" name="NOSPAM" value="SPAM" /> <p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" class="input" onclick="nospam();"/> </p> </form> I would like to get the captcha to work maybe this can stop them? Where would i apply this? $posttext = "how ever you retrieve your text posted from the submit form"; if (eregi("advertisment", $posttext)) { echo "Your post matches words that are related to advertisments, please refrain from using these words." }
  6. dont think i applied it right coz i am still getting spam adverts! i put this in the javascript: function nospam() { document.book.NOSPAM.value = "NOSPAM"; return true; } and i added this to my form: <form method="post" action="../process.php" name="book" enctype="multipart/form-data" onsubmit="return checkForm()"> <input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" class="input" onclick="nospam();"/> i wasnt sure where to put this so i didnt add it: if ($_REQUEST['NOSPAM'] !== 'NOSPAM') { # Whoops, someone didn't click the button. print "This site requires javascript, blah blah blah"; }
  7. please help i need to stop this spam bot!
  8. Ive tried adding the below code to the process.php but its not working: <?php if(isset($_POST['captchacode'])){ if(sha1($_POST['captchacode']) == $_SESSION['captcha']){ //add the comment to db or whatever } else{ echo "The code u provided is invalid. Try again."; } } ?> This is how my process.php looks: <?php if (isset($_POST['submit_comment'])) { if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comment'])) { die("You have forgotten to fill in one of the required fields! Please make sure you submit a name, e-mail address and comment."); } if(sha1($_POST['captchacode']) == $_SESSION['captcha']){ //add the comment to db or whatever } else{ echo "The code u provided is invalid. Try again."; } } $entry = htmlspecialchars(strip_tags($_POST['entry'])); $timestamp = htmlspecialchars(strip_tags($_POST['timestamp'])); $name = htmlspecialchars(strip_tags($_POST['name'])); $email = htmlspecialchars(strip_tags($_POST['email'])); $url = htmlspecialchars(strip_tags($_POST['url'])); $comment = htmlspecialchars(strip_tags($_POST['comment'])); $comment = nl2br($comment); if (!get_magic_quotes_gpc()) { $name = addslashes($name); $url = addslashes($url); $comment = addslashes($comment); } if (!eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) { die("The e-mail address you submitted does not appear to be valid. Please go back and correct it."); } include "connect.php"; @ mysql_connect($server, $connect, $pass) or die(__LINE__. mysql_error()); @ mysql_select_db($database) or die(__LINE__. mysql_error()); $result = mysql_query("INSERT INTO php_blog_comments (entry, timestamp, name, email, url, comment) VALUES ('$entry','$timestamp','$name','$email','$url','$comment')"); header("Location: entry/journal.php?id=" . $entry); } else { die("Error: you cannot access this page directly."); } ?>
  9. This is how my form looks.. I think I have done it wrong: <form method="post" action="../process.php"> <p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>"> <strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="25" /><br /> <strong><label for="email">E-mail:</label></strong> <input type="text" name="email" id="email" size="25" /><br /> <strong><label for="url">URL:</label></strong> <input type="text" name="url" id="url" size="25" value="http://" /><br /> <strong><label for="comment">Comment:</label></strong><br /> <textarea cols="25" rows="5" name="comment" id="comment"></textarea></p> <img src="captcha.php" /> <strong><label for="captchacode">Code:</label></strong> <input type="text" name="captchacode" id="captchacode" size="25" value="<?php if(isset($_POST['captchacode'])){ if(sha1($_POST['captchacode']) == $_SESSION['captcha']){ //add the comment to db or whatever } else{ echo "The code u provided is invalid. Try again."; } } ?>"/><br /> <p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" /></p> </form>
  10. How can I make comments get admin approval? This JS way sounds complicated. Id like to learn it but I havent got a clue how to do it.. Hi GuiltyGear! I have made the new page captcha.php with the PHP you have provided and I have added <img src="captcha.php" /> just about the comment submit button. I am a bit stuck on how to / where to add this: sha1 encrypted $_SESSION['captcha'] ? ? Every time I refresh the page a new image with different numbers appear so its nearly working If I add the code below at the top of the comments page will it work (is it that simple)? $ip = GetHostByName($REMOTE_ADDR); $handle = fopen('logs.txt', 'w'); fwrite($handle, $ip); fclose($handle);
  11. Hi everyone I am now experiencing a menace that is adding comments to my blog entries for no reason. I have searched this forum for answers and I have also read this page: http://www.sitepoint.com/article/stop-comment-spam I would like to try and install captcha into my comment form and if possible I would like to get the IP of this pesky user and BAN them from using my comments form forever! I am not sure how to install captcha or how to get the users IP and then to ban the IP. Please can someone help me stop this spammer and help me install a solution! This is the code for my comments page (comment form is at the end): <?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); while($row = mysql_fetch_array($result)) { $date = date("l F d Y", $row['timestamp']); $title = stripslashes($row['title']); $entry = stripslashes($row['entry']); $image = stripslashes($row['image']); ?> <?php $sql = "SELECT *, DATE_FORMAT(timestamp, '%a.%b.%y') as dateAdded FROM php_blog WHERE id='$id' ORDER BY timestamp"; $result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error()); 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 id='thisimage$i' onmouseover='showdiv(this.id);' onmouseout ='hidediv();' src='../entry/blog_images/".showinweb($row['image'])."' alt='' /> "; echo "<br />".showinweb($row['dateAdded']); echo "</div>"; } ?> <?php } } else { echo "<p><strong>" . $title . "</strong></p>"; printf("<form method=\"post\" action=\"journal.php?id=%s\"><p><strong><label for=\"username\">Username:</label></strong><br /><input type=\"text\" name=\"username\" id=\"username\" /></p><p><strong><p><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /></p></form>",$id); print "<hr /><br /><br />"; } } else { ?> <?php $sql = "SELECT *, DATE_FORMAT(timestamp, '%a.%b.%y') as dateAdded FROM php_blog WHERE id='$id' ORDER BY timestamp"; $result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error()); 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 id='thisimage$i' onmouseover='showdiv(this.id);' onmouseout ='hidediv();' src='../entry/blog_images/".showinweb($row['image'])."' alt='' /> "; echo "<br />".showinweb($row['dateAdded']); echo "</div>"; } ?> <?php } } $commenttimestamp = strtotime("now"); $sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp"; $result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error()); while($row = mysql_fetch_array($result)) { $timestamp = date("l F d Y", $row['timestamp']); echo "<div class='box1'>"; echo "<br /><br />".smiley(showinweb($row['comment'])); printf("<p>Comment by <a href=\"%s\">%s</a> @ %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp); echo "</div>"; } ?> <form method="post" action="../process.php"> <p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>"> <strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="25" /><br /> <strong><label for="email">E-mail:</label></strong> <input type="text" name="email" id="email" size="25" /><br /> <strong><label for="url">URL:</label></strong> <input type="text" name="url" id="url" size="25" value="http://" /><br /> <strong><label for="comment">Comment:</label></strong><br /> <textarea cols="25" rows="5" name="comment" id="comment"></textarea></p> <p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" /></p> </form>
  12. After trying alot of tutorials on breadcrumbs I have found this one the best so far: http://gr0w.com/articles/code/php_breadcrumb_links_creator/ I have got it to work on my home page but when I use it on another page it doesnt work :-\ On my homepage in dreamweaver I have put this php code on my footer because this is where I want my breadcrumbs: <?php $pagetitle="Home"; include("http://www.newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php"); ?> This is inside the included file breadcrumb.php: <?php $ul_id='crumbs'; $bc=explode("/",$_SERVER["PHP_SELF"]); echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/">Home</a></li>'; while(list($key,$val)=each($bc)){ $dir=''; if($key > 1){ $n=1; while($n < $key){ $dir.='/'.$bc[$n]; $val=$bc[$n]; $n++; } if($key < count($bc)-1) echo '<li><a href="'.$dir.'">'.$val.'</a></li>'; } } echo '<li>'.$pagetitle.'</li>'; echo '</ul>'; ?> When I view the page source of my homepage in firefox this is the code I see: <ul id="crumbs"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/">Home</a></li><li></li></ul> I am not sure why there are so many </li>? I have put the code below on my contact page: <?php $pagetitle="Contact"; include("http://www.newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php"); ?> When I view the contact page it still says Home and not Home > Contact :-\ :-\ ??? I tried adding a second $pagetitle2: <?php $pagetitle="Home"; $pagetitle2="Contact";include("http://www.newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php"); ?> and in the breadcrumb file I have added this: echo '<li>'.$pagetitle.'</li>'; echo '<li>'.$pagetitle2.'</li>'; Nothing seems to work. I thought this was supposed to be easy lol Please can someone help!?
  13. I have a table called comments and a field inside this table called entry. One of the values in the entry field is 7 but I want it to change to 3. I have another field called ID where entry 7 (the one I am trying to change) has the ID of 20. Basically something like this: where id=20 change entry=7 to 3 The line of code below is is what I have tried to use to change the ID of this entry but it didnt work (I have tried other variations). $result = mysql_query("UPDATE php_blog_comments SET entry='3' WHERE entry=7; ") or print ("Can't update entry.<br />" . mysql_error()); In the browser it says query was empty I want to change entry 7 to entry 3. Is this possible?
  14. Hi everyone I have made my own PHP blog. I would like to make my blog form more advanced so when I wraped [ur|] [/url] around some text it will then be a link on the index page where my blog entries display. I am having trouble doing this.. On the index page I have this code which works for bold tags: $find[] = "[b]"; //Look for bold tag $replace[] = "<span style='font-weight: bold;'>"; //Replace with span tag $find[] = "[/b]"; //Look for bold end tag $replace[] = "</span>"; //replace with end span I changed the above code to the code below hoping it would work but the browser gave me an error: $find[] = "[url=http://"; //Look for bold tag $replace[] = "<span class="class2"><a href="http://www.experts-exchange.com" onclick="window.open (this.href, 'child'); return false">"; //Replace with span tag $find[] = "]"; //Look for bold tag $replace[] = "<span class="class2"><a href="http://www.experts-exchange.com" onclick="window.open (this.href, 'child'); return false">"; //Replace with span tag $find[] = "[/url]"; //Look for bold end tag $replace[] = "</a></span>"; //replace with end span Ultimately I would like the links to look like this sites: http://www.tanfa.co.uk/css/articles/css-borders-design.asp :o Another problem I encountered which is not so serious is the code tag that changes the background colour. I have achieved this but if I add a border to the code it repeats the top border on every new line.. This is a screenshot of what it looks like using a border: This is the code for the border: $find[] = "[code]"; //Look for code tag $replace[] = "<span style='border-style: outset; background-color:#646464; color: white;'>"; //Replace with span tag $find[] = " "; //Look for code end tag $replace[] = "</span>"; //replace with end span[/code] Any ideas how I can get the links to work and fix the border problem? I dont mind trying a new method either!
  15. I can submit a new blog entry and when I view it on the index page it shows everything apart from the date. These are the fields in my blog table: timestamp, title, entry, password and image. All of these work apart from the timestamp.. When I the new entry data in the php_blog table the timestamp is 00000000000. I do have an edit form that lets me edit an entry and change the date successfully. This is a pain however because I want the timestamp to be entered into the database with new entries. The link below is the code for the new blog entry form: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/upload.phps This link allows me to edit/update entries: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/update.phps What I need to do is use some of the update code and apply it to the upload code.. I am having trouble doing this. I have tried various code combinations but I havent been successful. Please can someone point out what I am doing wrong!!!!!! ???
  16. I am trying to get the dates to show on the index page when a blog entry has been submitted using the form code below: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/upload.phps The date of the new entry is 00000000. I have an edit entry form that lets me update the new entries successfully using this code: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/update.phps On the update form I tried adding $current_time = time(); but it didnt work What am I doing wrong?!
  17. Ok I fixed the months problem.. I changed this: <?php for ($i=1;$i<13;$i++) { $checked = ($i==$row['old_month'])? " selected='selected' " :""; echo "<option $checked; value='$i'>".date('F','2006-'.$i.'-12')."</option>"; } ?> too: <?php for ($i=1;$i<13;$i++) { $checked = ($i==$row['old_month'])? " selected='selected' " :""; echo "<option $checked; value='$i'>".date('F',mktime(0,0,0,$i,12,2006))."</option>"; } ?> Months work perfectly now I am still trying to figure out how to fix the comments problem..
  18. I have this on the blog entry form: Line 92: $timestamp = strtotime($month . " " . $date . " " . $year . " " . $time); Line 195: <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> When I select March from the drop down menu and submit the new blog entry the date doesnt even show.. I then have to edit the entry using the update entry form to apply a date to the entry. This kinda works apart from the month. I can change the day and year successfully for some reason in the drop down menu for the months they all say January ??? This is the code for the drop down menu that shows only January: <?php for ($i=1;$i<13;$i++) { $checked = ($i==$row['old_month'])? " selected='selected' " :""; echo "<option $checked; value='$i'>".date('F','2006-'.$i.'-12')."</option>"; } ?> Update form PHPS: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/update.phps Add new blog entrys form PHPS: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/uploader.phps
  19. I removed - between date and time on the update page: $timestamp = "$year-$month-$date $time"; I can now change the days and years successfully. Only one problem left and that is the months..All the options in the drop down menu on the update page say January. This is the code being used: <select name="month" id="month"> <?php for ($i=1;$i<13;$i++) { $checked = ($i==$row['old_month'])? " selected='selected' " :""; echo "<option $checked; value='$i'>".date('F','2007-'.$i.'-12')."</option>"; } ?> </select> Only ideas why it just lists January? I have also just realized that the entries people have left comments it used to display: For example the entry titled "Missions" if you click "Leave a comment" you can see Igor has left a comment.. This used to say "1 comments" but now it says "Leave a comment" forgetting that someone has left a comment??? http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/index_vege.php?page=4
  20. I tried: $newdate = strtotime('October 31 2006'); mysql_query("UPDATE `php_blog` SET `timestamp` = '$newdate' WHERE `id`='1'"); Browser: My posts have an ID and a Record field. The link below is a screenshot of the blog table showing the entires and fields: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/images/view_date-01.gif The ID field lists the entries in this order: 1, 2, 88, 89, 7, 33, 32, 62, 85, 90, 92. I want to reset the blog but before I do this I need to know how to change the 0000000 entries to their original date so I can then reset, re-enter entries and then edit dates. I tried: mysql_query("UPDATE php_blog SET timestamp='".time(October 31 2006)."' WHERE id='1"); The browser responded with an error from the query: Parse error: parse error, unexpected T_LNUMBER in /blog/entry/update_timestamp.php on line 6 In this query I am trying to change ID 1 to October 31 2006. ID 1 on the index page is titled "Portfolio PHP blog!" and next to "Leave a comment" should be the date like the entries above. When you rollover "Leave a comment" the URL says "ID=1". When you click on leave a comment the next page says "Posted on Thursday January 01 1970".. I need to change this to October 31 2006 URLfor the index page: http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/index_vege.php
  21. I also got query was empty with CURRENT_TIMESTAMP.. I can edit everything else apart from the timestamp using a form. I am trying to do it manually because when I edit an entry the date is lost changing to 00000000 shown in the picture above.. $currenttime = date('Y-m-d H:i:s'); mysql_query("UPDATE `php_blog` SET `timecode` = '$currenttime' WHERE `id`='1'"); where do i put (0,0,0,10,31,2006) I tried: $currenttime = date(0,0,0,10,31,2006'); mysql_query("UPDATE `php_blog` SET `timecode` = '$currenttime' WHERE `id`='1'"); Browser:
×
×
  • 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.