Jump to content

sKunKbad

Members
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by sKunKbad

  1. echo $category; ?
  2. If you can test your sql directly on the database, from either the command line or phpMyAdmin, it may give you a clue as to why it's not working. If you can't do this, isolate your insert query and check it that way (with mysql_error())
  3. remove $result = and see what happens
  4. use spell check $querey in your PHP Form Handler Code
  5. OK, I fooled around with it and got it working: <?php $str = "Please go visit http://www.mysite.com/index.php?action=whatever"; $str .= " Please go visit http://www.mysite.com"; $str .= " Please go visit www.mysite.com"; function transformUrl($str){ $str=utf8_decode(urldecode($str)); $str=eregi_replace("(^| |>)(www([.]?[a-zA-Z0-9_/-?])[^< ]*)", "\\1<a href=\"http://\\2\">\\2</a>", $str); $str=eregi_replace("(^| |>)(http://www([.]?[a-zA-Z0-9_/-?])[^< ]*)", "\\1<a href=\"\\2\">\\2</a>", $str); $str=eregi_replace("(^| |>)(http://([.]?[a-zA-Z0-9_/-?])[^< ]*)", "\\1<a href=\"\\2\">\\2</a>", $str); return utf8_encode($str); } echo transformUrl($str); ?>
  6. Take a look at this: http://www.php.net/manual/en/function.eregi-replace.php#79451 It may be exactly what you need
  7. the last line, right after </a> and before the "
  8. Well, your missing the / delimiter at the end of your regex. Perhaps that is why your preg_replace isn't working?
  9. <?php $TPL_last_auctions_value .=" <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td width=\"10%\" align=\"center\"><p style=\"background-color:$bgcolor;display:block\"><center>"; if($hours < 24){ $TPL_last_auctions_value .= "<FONT FACE=ARIAL COLOR=GREEN><B>Listed Today</B></FONT>"; } if($hours > 0 && $hours < 1){ $TPL_last_auctions_value .= "<FONT FACE=ARIAL COLOR=GREEN><B>Just Listed</B></FONT>"; } $TPL_last_auctions_value .= "</center></td> <td align=\"left\"> $city_details1, $state1</B> - to - <B>$city_details2, $state2</B><BR> <A HREF=\"./item.php?id=$id\">"; ?>
  10. You should examine a book that talks about php security. I can see no validation of variables in your provided scripts. If at some point your script is querying the database for the values of $date and $source_id, it may not take much for a clever hacker to inject some malicious SQL into your database.
  11. Of course you can post with AJAX, but what if the user has javascript disabled? This is what I have done in the past: 1) try to set a cookie with javascript before the user gets to the form. 2) on the form page, verify if the user has javascript enabled by checking for the cookie using php. 3) if javascript is disabled, post to a validation/cURL script and output a thank you or error message. 4) if javascript is enabled, post with AJAX to the validation/cURL script, output a thank you or error message. This works, and it falls back on php in case javascript is disabled. The advantage is that the user doesn't have to wait for the lag of the validation/cURL script if they have javascript enabled.
  12. I always validate the form using regular javascript, then send the full post to the php script where it is validated a second time. It may seem like overkill, but you can't rely on javascript being on, and therefore can't rely on AJAX working.
  13. In the book "object oriented programming", the author has a function that checks that all files in a directory are images: function checkAllImages(){ $bln=true; $extension=''; $types= array('jpg', 'jpeg', 'gif', 'png'); foreach ($this->filearray as $value){ $extension = substr($value,(strpos($value, ".")+1)); $extension = strtolower($extension); if(!in_array($extension, $types)){ $bln = false; break; } } return $bln; $filearray is an array of all of the files in the directory.
  14. So just modify the script. I cut and pasted it as an example. I'm not going to do all of the work. It shouldn't be hard to modify, even for a beginner.
  15. <?php session_start(); echo count($_SESSION['randomNums']) . "<br>"; print_r($_SESSION['randomNums']); function randomNoRepeat(){ $max= 6; $num = Rand (1,$max); if(isset($_SESSION['randomNums']) && in_array($num,$_SESSION['randomNums'])){ if (count($_SESSION['randomNums']) == 6){ switch ($num) { case 1: echo "Time is money"; break; case 2: echo "An apple a day keeps the doctor away"; break; case 3: echo "Elmo loves dorthy"; break; case 4: echo "Off to see the wizard"; break; case 5: echo "Tomorrow is another day"; break; case 6: echo "PHP is cool!"; } unset($_SESSION['randomNums']); }else{ randomNoRepeat(); } }else{ switch ($num) { case 1: echo "Time is money"; $_SESSION[randomNums][] = $num; break; case 2: echo "An apple a day keeps the doctor away"; $_SESSION[randomNums][] = $num; break; case 3: echo "Elmo loves dorthy"; $_SESSION[randomNums][] = $num; break; case 4: echo "Off to see the wizard"; $_SESSION[randomNums][] = $num; break; case 5: echo "Tomorrow is another day"; $_SESSION[randomNums][] = $num; break; case 6: echo "PHP is cool!"; $_SESSION[randomNums][] = $num; } } } randomNoRepeat(); ?>
  16. You might try an email class like phpmailer, or a formmail script like one from tectite.com
  17. I'm curious if using Apache user authentication (.htpasswd) with either shared or dedicated SSL is considered ~100% safe from hacking. I have a folder and associated files of a website that I need to protect. I have already used .htpasswd, which is very easy, and have used a shared SSL certificate, but have never used a dedicated certificate.
  18. I can't tell you why your From name doesn't work. When I was using a windows server to send mail, I had to use: ini_set("SMTP","mail.yourdomain.com"); ini_set("smtp_port","25"); The standard format for sending mail through php's mail function is: $to = $email; $subject = 'This is email, duh'; $message = 'I want to go home.'; $headers = "From: me <me@bored.com>\r\nReply-To: me@bored.com\r\nReturn-Path: ime@bored.com"; mail( $to, $subject, $message, $headers );
  19. <?php // this file shows how to list the files in a specific directory //works with php4 if ($handle = opendir('/home/content/img')) { echo "Directory handle: $handle\n"; echo "Files:\n"; while (false !== ($file = readdir($handle))) { if($file != "." && $file != "..") { echo "$file<br />\n"; } } closedir($handle); } //works with php5 echo "The name of this file, including full server path is: ".$_SERVER['SCRIPT_FILENAME']. ".<br />The following is the list of files withing the same directory<br /><br />"; $d = scandir('C:/wamp/www/script_library/'); foreach($d as $f) { if ($f != '.' && $f != '..') { echo $f . "<br />"; } } ?> This doesn't insert the files into the database, but I was just being lazy.
  20. I don't believe that <> will work as a comparison operator, try: if($flag == 'OK'){ }
  21. I remember an instance when I was working on a customer's project, and the body of the email would not send until the actual body was flush with the left side of the code. Here is what I found in my code when I looked: //THIS MUST STAY PARKED OVER ON THE LEFT SIDE OF THE CODE *** DO NOT INDENT THIS TO KEEP THE CODE PRETTY OR IT WILL NOT WORK! $message = " --PHP-alt-$random_hash Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $textEmail --PHP-alt-$random_hash Content-Type: text/html; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $htmlEmail --PHP-alt-$random_hash-- "; // END MESSAGE BODY AREA
  22. Just to test, if you run the script with echo report(), does it show the expected output? Also, if you send a simple email replacing the $body = report() with $body = "Hello", then what happens?
  23. You might just take a look at the documentation for mysql_connect and mysql_query. It looks like these are the only functions you would need. http://us3.php.net/manual/en/function.mysql-connect.php <= mysql_connect http://us3.php.net/manual/en/function.mysql-query.php <= mysql_query
  24. In the following code, the yellow box should be 100px tall, half on top of the white box, and half on top of the green box. IE7, Firefox, Opera, and Safari display this fine, but IE6 cuts the top half of the yellow box off. Any help is appreciated. <div style="float:left; width:100%; height:100px; border: solid red 1px;">Box 1</div> <div style="float:left; width:50%; height:100px; border: solid black 1px; background-color:green;"> <div style="float:left; width:50%; height:100px; border: solid black 1px; background-color:yellow; margin-top:-50px;">Box 2</div> </div>
×
×
  • 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.