Jump to content

Pilot-Doofy

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Everything posted by Pilot-Doofy

  1. I hate it when a powerful language is put to horrible use.
  2. Just write them in any free C++ IDE, is that what you mean?
  3. I'm recoding some of my forums and I'm trying to prevent the overuse of slow functions such as explode(); etc. I decided a more formal approach would be a regular expression. However, when I run the regular expression how would I run a function on the string that is returned? Here is my regular expression: $string = preg_replace('#(\[code\])(.+)(\[/code\])#si', '\\2', $string); I have the string returned between the code tags but here is what I tried to do: $string = preg_replace('#(\[code\])(.+)(\[/code\])#si', hightlight_string('\\2'), $string); How would I get the highlight_string(); function to work with the text that is between the tags? This doesn't work.
  4. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Email Contact Form</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $master = 'your_email@domain.com'; ## Edit this line to include your email ## between the single quotes error_reporting(ALL); if (!isset($_POST['Submit'])) { echo '<form action="' . $HTTP_SERVER_VARS['PHP_SELF'] . '" method="post" name="email_form" id="email_form"> <table width="100%" border="0" cellspacing="0"> <tr> <td width="22%">Your Name: </td> <td width="78%"><input name="name" type="text" id="name" size="30"></td> </tr> <tr> <td>Email Subject:</td> <td><input name="subject" type="text" id="subject" size="40"></td> </td> <tr> <td>Email to Send to: </td> <td><input name="to" type="text" id="to" size="40"></td> </tr> <tr> <td>Email Body: </td> <td><textarea name="body" cols="35" rows="6" id="body"></textarea></td> </tr> <tr> <td>Email to Send from: </td> <td><input name="from" type="text" id="from" size="40"></td> </tr> <tr> <td>Submit Email: </td> <td><input type="submit" name="Submit" value="SEND EMAIL!"></td> </tr> </table> </form>'; } else { # Submitted the form $name = $_POST['name']; $from = $_POST['from']; $body = $_POST['body']; $to = $_POST['to']; $subject = $_POST['subject']; if (!isset($_POST['to'])) { $error = true; $msg = 'Error: You must specify an address to send the email to.'; } if (!isset($_POST['body'])) { $error = true; $msg = 'Error: You must specify a body for the email.'; } if (!isset($_POST['name'])) { $name = 'anonymous'; } if (!isset($_POST['from'])) { $from = 'nowhere@site.com'; } if (!isset($_POST['subject'])) { $subject = '(no subject)'; } $body .= "\n"; $body .= '(This email was sent from ' . $name . ' at ' . $from . ') -- Note: This email was sent via an automated form and this information may not be correct.'; if ($error === true) { echo $msg; exit; } else { # No errors $send_mail = mail($to, $subject, $body, "From: $from\nX-Mailer: PHP/ . $phpversion()", "-f $from"); $send_mail_two = mail($master, $subject, $body, "From: $from\nX-Mailer: PHP/ . $phpversion()", "-f $from"); if (!$send_mail) { $msg = 'Error: Email could not be sent at this time.'; } else { $msg = 'Success! Email was sent.'; } } // End else for if ($error === true) echo $msg; } // End else for if (!isset($_POST['Submit'])) ?> </body> </html>
  5. Is it phpBB or another system? It most likely has an installation page you must fill out with your correct database information.
  6. If he already has a working version of easyphp 1.8, don't try to get him to change. Don't fix it if it isn't broken. To answer the author: First open up Dreamweaver. I will show you step by step how to setup a site definition in Dreamweaver and have it saved to your local folder. You must always have easyphp running when you want to test your php work. Your local website is available at http://localhost/ Here is the guide: Site > Manage Sites > Advanced Tab > Site name: Anything you want > Local root folder: C:\Program Files\EasyPHP1-8\www (I think that's right, if not, change it to your www folder for EasyPHP) > Default Images Folder: You don't have to define it but you can > HTTP Address: http://localhost/ > Remote Info Tab on Left > Access: Local/Network > Remote Folder: C:\Program Files\EasyPHP1-8\www (again it may or may not be correct) That should be it. If you have further problems let me know.
  7. You didn't need to bump this thread in the first place, someone would eventually get around to it. Considering you only waited a day I was reluctant to help you but since I'm a kind spirited person, I decided to continue with the help. Have you not read enough on SQL to see that it has an AND operator? Try this: $service = addslashes($_GET['service']); $type = addslashes($_GET['make']); # I know this isn't completely secure but it's a good start. You can work # the rest out. $get_info = mysql_query("SELECT * FROM cellphones WHERE service = '" . $service . "' AND make = '" . $type . "'") or die ("Error, could not run query. MySQL: " . mysql_error()); # After getting everything working or if you don't run into any problems # I would remove the or die statement. It is mainly used for only debuggin # and the user doesn't need to see the structure of your database to know # what exactly went wrong. if (mysql_num_rows($get_info) == 0) { echo 'No results found.'; } else { # Results were found echo 'Results:<br /><br /> do { # Execute code echo 'Service: ' . $info['service'] . '<br /> Make: ' . $info['make'] . '<br />'; } while ($info = mysql_fetch_array($get_info)); } // End else for if (mysql_num_rows($get_info) == 0) You can always retrieve the rest of the information from your database. I'm not sure if I got the table or fields right but I was just guessing. Fix them if needed.
  8. Not many problems in the above script except a few pet peeves and security issues. Let's address the not so important stuff first. Again as I always ask, why would you hide a variable inside of double quotes when coding in Dreamweaver? It makes the code a lot less readable and causing you hit Ctrl+F constantly searching for the variables. That doesn't actually matter but it's just a good habit to get into. The part I'm most concerned with is you're not preventing or even attempting to prevent malicious code from entering the database. Truth is, everyone out there isn't as good hearted as most of us are, so you want to make code that can slow their negativity down at least to a bare minimum. I would always get in the habit of using stripslashes(); and addslashes(); for retrieval and insertion of information, respectively. Secondly, you should check with a regular expression for common malicious SQL code that could be entering via the update page. That isn't as vital as the stripslashes(); and addslashes();, however. If you don't want to have to work yourself to death by using addslashes(); for $_POST, $_GET, or $_REQUEST information you can always turn magic quotes on in your php.ini file. While I keep mine turned on I still try to write all my code with addslashes(); and I like to have that attitude, "It will take me an extra 10 seconds to type in addslashes(); and stripslashes(); but it will take me 10 hours to figure out the problem if it gets hacked."
  9. The parentheses aren't need and why use escape characters when they're not needed? I wouldn't suggest hiding variables inside of double quotes, at least not when you're using Dreamweaver because Dreamweaver won't highlight variables inside of quotes. I just don't believe it's a good habit to get into. echo '<a href="' . $web . '">' . $web . '</a>'; If you know that your contents are going to involve only one style of quotes it's much simpler just to prevent escape characters and march on with the contradicting style for opening and closing the statement.
  10. By him saying, "I want it to show up on my website" I would assume he would need it saved on the server in some way, wouldn't you concur? However, I'll let you write the script because he has way too many fields and capitalization for me to bother. :-P Since you don't know whether or not he is capable of using MySQL or other databases for this I would write something universal to cause less problems. I suggest flat files. fopen(); fread(); fgets(); and fwrite(); should take care of it.
  11. I have a website at http://mustywindows.com and it needs some revisions to the code. I realize it is very unsecure with login systems etc and I would like to fix. The entire site was created with me only having a few months of php knowledge. Since I wrote most the code about 9-10 months ago, it is very slow and very insecure, as I mentioned before. I'm looking for someone who can help me update the code with more notes, delete redundant scripts, and make the pages filesize smaller which in return will cause it to load more quickly. Right now, I have a few pages over 20kb which is pretty large considering I revised just one and got it down to 2kb. I would like to know if anyone would like to help. I can award special privlages on the site but have no money for funds. I apologize.
  12. Do you want the different pages of text contained in a single page and only passing variables such as page.php?page=4 or whatever? If you just want different page it is very easy, just save different files. If you want them contained within one page you can use if statements, databases, file();, or a few other options. Please clarify.
  13. You can just do this: // replace <br> with <br /> even though i dont know why lol ## get all the stuff from the database $text = $array_retrieved_from_database['field']; // change this to fit $cur_id = $array_retrieved_from_database['field_id']; // change this to fit $text = str_replace("<br>", "<br />" $text); mysql_query("UPDATE table SET field = '$text' WHERE id = '$cur_id'"); Hope that helped.
  14. Its not that hard if you want something very basic, it can get as complex as you want.
  15. Try this, assuming you can change the variables accordingly. // variable for the $_POST $search_string = $_POST['searchfield']; if ($search_string == "") // asking if its empty { echo "Sorry, please <a href=javascript:history.go(-1);>go back</a> and enter something in the search field!"; } elseif ($search_string != "") // if its not empty, you an also use if (!empty($search_string)) { $query = "SELECT ID, BF, Vernacular, Taxon FROM species WHERE Vernacular LIKE '%colname%' ORDER BY Vernacular ASC"; $result = mysql_query($query); $result_total = mysql_num_rows($result); // see how many results were pulled if ($result_total == 0) // if nothing is returned in the search do this { echo "Sorry, no results matched your search criteria."; } if ($result_total > 0) // if results are actually brought up do this { echo "Congratulations! There were $result_total results found matching the criteria you searched for!"; // give loop to show all the results here } else // if something other than that goes wrong { echo "There was a problem outside the magical realm of my knowledge, try again."; } } mysql_close(); // close connections Try that, sorry if its wrong in some ways, I'm studying for my History exam.
×
×
  • 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.