Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
Use this javascript code: [code]location.href = 'new location here';[/code] Wrong forum by the way.
-
[code]<?php for($i=1;$i<=12;$i++) { $num .= chr(rand(48,57)); } echo $num; ?>[/code]
-
Try this: [code]<?php echo <<<EOF <style type='text/css'> body, table { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; } #message { margin-bottom: 1em; } #error { color: red; font-weight: bold; } </style> EOF; function show_form($message=null,$errors=array()) { foreach($_POST as $key => $value) { $_POST[$key] = htmlentities($value); } $message = !empty($message) ? "\n\t<div id='message'>{$message}</div>" : null; if(count($errors)) { $num_errors = count($errors); $error = <<<EOF <div id='error'>Please correct the following errors (total: {$num_errors}):</div> <ul> <li> EOF; $error .= join("</li>\n\t\t<li>",$errors); $error .= "</li>\n\t</ul>"; } echo <<<EOF <form method='post' name='tell_a_friend_form' action=''>{$message}{$error} <table> <tr> <td valign='top'><label for='sender_name'>Your name:</label></td> <td><input type='text' name='sender_name' id='sender_name' size='45' value='{$_POST['sender_name']}' /></td> </tr> <tr> <td valign='top'><label for='sender_email'>Your email:</label></td> <td><input type='text' name='sender_email' id='sender_email' size='45' value='{$_POST['sender_email']}' /></td> </tr> <tr> <td valign='top'><label for='recipient'>Your friend's email:</label></td> <td><input type='text' name='recipient' id='recipient' size='45' value='{$_POST['recipient']}' /></td> </tr> <tr> <td valign='top'><label for='subject'>Subject:</label></td> <td><input type='text' name='subject' id='subject' size='45' value='{$_POST['subject']}' /></td> </tr> <tr> <td valign='top'><label for='message'>Message:</label></td> <td><textarea name='message' id='message' rows='10' cols='45'>{$_POST['message']}</textarea></td> </tr> <tr> <td colspan='2'><button type='submit'>Send</button></td> </tr> </table> </form> EOF; } if(count($_POST)) { $errors = array(); if(empty($_POST['sender_name'])) { $errors[] = "Please write your name."; } if(empty($_POST['sender_email'])) { $errors[] = "Please enter your email."; } if(empty($_POST['recipient'])) { $errors[] = "Please write your friend's e-mail address."; } if(empty($_POST['subject'])) { $errors[] = "Please enter a subject."; } if(empty($_POST['message'])) { $errors[] = "Please enter a message."; } if(count($errors) < 1) { $headers = "From: {$_POST['sender_name']} <{$_POST['sender_email']}>\n\r"; if(@mail($_POST['recipient'],$_POST['subject'],$_POST['message'],$headers)) { show_form("Your message has been sent."); } else { show_form("Your message could not be sent! Please try again."); } } else { show_form(null,$errors); } } else { show_form(); } ?>[/code]
-
You shouldn't use that approach since it requires short tags on in php.ini. Instead you should use: [code]<?php echo html_entity_decode($message_text); ?>[/code]
-
Is there a ready industry-strong project in PHP available?
Daniel0 replied to agga.gaag's topic in PHP Coding Help
I don't know what you mean, but if you want to view something I think is good practices and good coding style, then check [url=http://icebb.net]IceBB[/url]'s source: http://svn.sourceforge.net/icebb It do not use Smarty, and it is probably not very well-commented (depending on your experience), but you could take a look anyways. -
I guess it would be fine to store it in one table, but it depends on what they are entering.
-
I would go for hosting a forum system myself. It is not that hard to install and it gives much more control. A good one could be [url=http://icebb.net]IceBB[/url], but 1.0 final has not been released yet. I just don't recommend phpBB.
-
Another good one is [url=http://pearlcrescent.com/products/pagesaver/]Pearl Crescent Page Saver[/url]. It saves a screenshot of the visible portion of a webpage or the entire page.
-
Donation button in forums
Daniel0 replied to karthikeyan_coder's topic in PHPFreaks.com Website Feedback
It's pay per impression, so it doesn't matter if anybody looks at them. I don't mind the current way either, but apparently karthikeyan_coder does. -
Try to post the script that posts the poem.
-
Use safe_mode then. Or, I'm not sure, but maybe if you use Linux you could chroot Apache to "jail" it inside it's own directories.
-
pndof12006: Let me explain how it works: \n (LF - line feed) - Linux uses this to display a new line \r (CR - carriage return) - Macintosh use this to display a new line \n\r (CRLF - carriage return, line feed) - Windows uses this to display a new line [url=http://php.net]nl2br[/url] converts LF to [tt][nobbc]<br />[/nobbc][/tt]. If you want to convert all types of new lines to \n, then use this: [code]$string = preg_replace("/(\r\n|\r|\n)/","\n",$string); $string = nl2br($string);[/code] Or perhaps even better: [code]$string = preg_replace("/(\r\n|\r|\n)/","<br />\n",$string);[/code]
-
[url=http://www.sitepoint.com/recentarticles/]Sitepoint[/url] has some great articles about a big variety of subjects, all concerning web development/website management.
-
[quote=their FAQ][b]Q: Do you offer a board configuration service?[/b] A: Yes. While the actual installation of your forum is done for you, setting up your forums is left to you. We do offer a configuration service for those who do not wish to take the time to set up their board. [color=red]For a fee of $10 we will configure your board[/color], including the installation of up to 5 styles, configuration of up to 5 usergroups, creation of up to 5 forum categories and 20 forums. Use the contact us form to arrange for your board configuration.[/quote] I think I found your "setup fee". [quote=their FAQ]Ad-free forums are available at just$5.00 a month![/quote] There goes your advertisments. [quote=their Terms of Service]All free forums at ForumsPlace.com are advertising supported. We reserve the right to place up to six (6) advertising units on each forum page. An advertising unit is defined for the purposes of this agreement as a graphical page element promoting a site or service that is not part of our network of free sites. Non-promotional static text links are not considered to be advertising, and are hence not included as an advertising unit. Up to two of ad units may appear in a prominent spot at the top of the page, while the remaining ones may be placed on the page footer, below the actual forum. Ad units may be removed by upgrading to one of our ad-free hosting plan when available. Any attempt to disable these ads will result in an immediate account termination. Directly contacting our advertisers in any way regarding our account(s) is strictly forbidden and may result in your account termination, with or without notice.[/quote] And even if it weren't in the ToS when you registered: [quote=their Terms of Service]This Terms of Service/Acceptable Use Policy may be amended, at any time, at the discretion of ForumsPlace.com. All accounts are required to comply with any changes made to these policies. Notification of any major changes to the policies will be emailed to the email addresses we have on file for all account holders. You are required to keep a valid and current email address on file with us, in your billing account.[/quote] I am afraid you should have read their FAQ and ToS before registering.
-
Other good ones are: [list] [*][url=https://addons.mozilla.org/firefox/966/]Tamper Data[/url] Makes you able to tamper all headers you send [*][url=https://addons.mozilla.org/firefox/2498/]Yet Another Window Resizer[/url] Well, resizes windows [*][url=https://addons.mozilla.org/firefox/1419/]IE Tab[/url] (windows only) Makes you able to use Internet Explorer within Firefox [*][url=https://addons.mozilla.org/firefox/1269/]Fasterfox[/url] Improves the speed [*][url=https://addons.mozilla.org/firefox/575/]Header Monitor[/url] View all the headers that the page has sent [/list]
-
Donation button in forums
Daniel0 replied to karthikeyan_coder's topic in PHPFreaks.com Website Feedback
In my eyes this is not a topic that is complaining about the advertisments, but a topic where (s)he wants to suggest how it could be improved, but (s)he hasn't replied back... I personally don't mind the advertisments, but here is a suggestion from me: Perhaps there could be shown a "reply" after every eg fifth reply with ads in? That would solve the problem with the [nobbc][code][/nobbc]-boxes -
To do Google-like searching ("bla3 bla1" -bla2 +bla3) you may use fulltext searching: [code]SELECT * FROM tablename WHERE MATCH (title,body) AGAINST ('"bla3 bla1" -bla2 +bla3' IN BOOLEAN MODE);[/code]
-
This might be old news to some, but due to a bug in Firefox the autoscroll can be customized. The way the autoscroll icon appears is that Firefox inserts an image in the page. The image is inside the html tag so it can actually be styled using CSS. You could use img to style all images, but that would ruin all images, so you could also use the child-of operator (or whatever it is) to only style images that are a direct children of the html tag (which yours hopefully isn't!!!). So by using this css code you can make the autoscroll image show up as the PHP logo for Firefox users: [code]html > img { width: 0!important; height: 67px !important; padding-left: 120px !important; background: url(http://php.net/images/php.gif); }[/code] An example of a website that actually uses it is [url=http://www.sitepoint.com/]Sitepoint[/url] (you obviously need to view it in Firefox to see it) Since this is actually a known bug (https://bugzilla.mozilla.org/show_bug.cgi?id=242466) this "functionality" may be removed, but since it was filed in 2004 it might stay for some time. Source: [url=http://www.sitepoint.com/]Sitepoint[/url]
-
I've noticed that if you log out on the main page you get logged out on the forums as well. Does that mean you have merged the accounts?
-
moving data within a textarea field to a text file
Daniel0 replied to gentlemanintraining's topic in PHP Coding Help
[code]<?php $filename = md5(microtime()); $fp = fopen("files/{$filename}",'w'); fwrite($fp,$_POST['file_contents']); flclose($fp); mysql_query("INSERT INTO ......"); ?>[/code] -
Donation button in forums
Daniel0 replied to karthikeyan_coder's topic in PHPFreaks.com Website Feedback
I guess he means one of those PayPal donation buttons or a link to [url=http://www.phpfreaks.com/donations.php]PHP Freaks' donation page[/url]. -
Donation button in forums
Daniel0 replied to karthikeyan_coder's topic in PHPFreaks.com Website Feedback
[quote author=steelmanronald06 link=topic=111503.msg452001#msg452001 date=1160879007] As per phpfreak's thread, google adsense is here to stay and is not up for discussion otherwise. comments on it can be made in this thread: http://www.phpfreaks.com/forums/index.php?topic=110155.0 topic closed! [/quote] It is a little hard to discuss it/make comments on it in that topic when the topic is closed... Just because phpfreak said that it is going to stay, then I don't it doesn't mean that it wont be improved if anybody suggests a better way to do it. -
Try to change the encoding to utf-8: [code]header("Content-type: text/html; charset=utf-8");[/code] Note: Put this BEFORE anything is output.
-
Make sure that your checkbox has a non-empty value attribute.
-
Try reading the tutorial [url=http://www.phpfreaks.com/tutorials/139/0.php]Creating dynamic RSS feeds[/url] :) It should help you with creating a dynamic RSS feed.