Jump to content

Johnny2

Member
  • Posts

    52
  • Joined

  • Last visited

Everything posted by Johnny2

  1. Concerning Forms: When I submit my form, I'm getting "Undefined index" errors everywhere a checkbox is NOT checked. However, I do not get errors from my textareas which I did not fill in, nor my input (type="text") fields which I did not fill in. Why do checkboxes produce this error if they are not filled in? It's as if they are not posting anything when the form is submitted. Shouldn't they at least be posting '' as the value? It looks as if the $_POST['name1'] is simply not getting set in the case of the unchecked checkbox. What am I missing? How can I solve this issue? Here is an example of my checkbox input field, I THINK it's structured correctly (and the php code is to have the box still checked for the user if the form is re-shown to them if they have to fill in more information or whatever): <label> <input type="checkbox" name="name1" value="y" <?php if($name1=="y"){echo "checked";} ?>> Would you like Name 1?</label>
  2. I have a client who wants his website to sell products from many different warehouses (which also use different combinations of shipping companies). I can collect information about shipping-dimensions and shipping-weight for each product, but how do I calculate what the shipping will/should be so the customer will know before checkout? I assume it will have to be calculated with each warehouse's zip-code and the customer's zip-code, but don't know how to get the information in an automated way. I assume that many other online companies do this very thing, but I guess I'm missing the basics of how to get the information. I mean... does UPS, FedEx, and USPS have a URL that my script can POST the zipcodes and shipping-weight to, then sends information back to my script? Thank you e-commerce Gurus!
  3. Thanks Ben, Do you feel that the incomming data should be rendered harmless if I initially "clean" it with this line of code?: $data_cleaned = preg_replace('#[^A-Za-z]#i', '', $data_dirty);
  4. I'm trying to include a file, but want to show the file at a specific location. I figured I'd just use a named anchor in my include, but it doesn't seem to work. Is there a way to do this?... or am I once again trying to do something impossible? I know I can probably use a regular link to go to that specific location on the page, but in my situation I need to "include" the other file (so that my variables will still be defined). include(otherFile.php#anchor); Thanks!
  5. When I run code just to check if the $_GET is set, can this (possibly malicious) data be harmful in this instance?... Do I only need to clean the data if I'm going to use it in a calculation or something? if (isset($_GET['badGuyData']) { } Thank you.
  6. Hey everyone! I'm trying to find the best way to clean some incoming POSTed data (to protect me from the bad guys of course), and was wondering if htmlentities is doing anything useful for me if I'm just going to strip the incoming data of everything except letters and numbers anyway. Question #1: Can the htmlentities line be removed without affecting security in any way? Question #2: Is using preg_replace like this an effective way to secure my website from this incoming data? $name_dirty = htmlentities($_POST['name'], ENT_QUOTES); $name_cleaned = preg_replace('#[^A-Za-z]#i', '', $name_dirty); Thank you Developer-Guru's!
  7. Johnny2

    Preg_Match()

    Thanks for your reply Strider. I am not looking to replace anything. I simply want to test if there is one (or more) swear-words in the string. I know how to use preg_match to test for a single swear-word. I just need to know how to write the command so that I can look for many swear words at the same time. Do you know how to do this? Thanks
  8. Yes, I understand that I can simply do a google search for free clipart. The reason I was asking on here was because web-developers would have a little insite as to which ones were LEGITIMATE. Any Joe-Shmoe can build a website which could "claim" to provide legal & free clipart...
  9. Anyone know a well-known site to get clipart or other images that are completely free to use on a commercial site without fear of copyright or license issues? Thanks
  10. Johnny2

    Preg_Match()

    I'm trying to use preg_match() properly to search a string for any of several words. Basically I'm testing if a string contains a naughty word. This doesn't seem to work: preg_match("/word1/word2/word3/",$string_to_examine); What am I missing?
  11. I'm trying to grab data about products stored in my database, then shuffle the array contents to be able to later display the products in a random fashion. I'm having trouble understanding the initial data-grab, and therefore the initial array I need to work with. For instance: $sql=mysql_query("SELECT * FROM products"); Is $sql a variable that now holds an array of arrays from the info from my database? I assumed that, but when I var_dump it, it gives me: resource(5, mysql result) So, then I put in : $productArray = mysql_fetch_array($sql); echo var_dump($productArray); This gives me an array, BUT only for the first item-array, when there should be several arrays in $sql somewhere. So, where in the heck is all the data I got from the database query (for all the other products)? Can someone please help me understand whatever concepts I am missing here? Thank you tons! :)
  12. I'm trying to calculate the difference between timestamps. Can't figure out why it's not working. The particular line of code that isn't giving me what I expect is: $difference = abs(($timestamp)-($birthday)); I'm expecting a result of the number of seconds between the two timestamps. Below is all of the webpage code: <?php //creates a timestamp for right now $timestamp=strtotime("now"); //formats a timestamp into a human-readable form $date = date("Y m d H:i:s",$timestamp); //defines Birthday $birthday = "August 14, 1975"; //takes a date and converts it to a timestamp. strtotime(timeStringToParse,timestamp) ommit timestamp to use current time (whatever that means) $convertedtotimestamp = strtotime($birthday); //calculates the difference between two timestamps (in seconds) $difference = abs(($timestamp)-($birthday)); //difference converted into human-readable format (years in this case) $diffReadable = ($difference/60/60/24/365); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Working with timestamps</title> </head> <body> <?php echo "current timestamp:"; echo "<br />"; echo $timestamp; echo "<br />"; echo "<br />"; echo "today's date:"; echo "<br />"; echo $date; echo "<br />"; echo "<br />"; echo "Birthday:"; echo "<br />"; echo $birthday; echo "<br />"; echo "<br />"; echo "Birthday's timestamp:"; echo "<br />"; echo $convertedtotimestamp; echo "<br />"; echo "<br />"; echo "the difference between today and birthday (in seconds)"; echo "<br />"; echo $difference; echo "<br />"; echo "<br />"; echo "Age: "; echo "<br />"; echo $diffReadable; ?> </body> </html>
  13. Oh. Well then, I'll stop trying. Hahaha. Thanks Ben!!!
  14. I'm just trying to get a default value to show up in a form field (type=file) using the example below. Anyone know what I'm missing? I know the variable $imagefile is being populated correctly because I've tested it. Is it just something I'm missing in the html input tag at the bottom? // above in the php script: if (isset($_GET['id'])) { $targetID = $_GET['id']; $sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1"); } while($row = mysql_fetch_array($sql)){ $imagefile = 'images_folder/' . $targetID . '.jpg'; } <!-- below in an html form: --> <input type="file" name="fileField" id="fileField" value="<?php echo $imagefile; ?>"/>
  15. I've reserched the problem and found my solution. Something tells me that A LOT of newbies at web development are going to run into this problem. The solution: Left-click the Wamp icon -> Click Apache -> Alias Directories -> http://localhost/phpmyadmin/ -> Edit alias -> You should now be in the phpmyadmin configuration. Change this line near the bottom: Allow from 127.0.0.1 to this: Allow from 127.0.0.1 ::1 I was golden at this point. Hooray!
  16. I've installed WAMP so that I can test my PHP code, as the Killersites tutorials instructed. It seems to work well since I can pop open a browser, point it to localhost, and I see the results of my processed PHP code. However, I'd also like to create a database... so, when I go to do that by clicking the WAMP icon (in the quicklaunch area) then click phpMyAdmin, it gives me this error message: This error (HTTP 403 Forbidden) means that Internet Explorer was able to connect to the website, but it does not have permission to view the webpage. What am I missing? I uninstalled the 64-bit version I first had and installed the 32-bit version with the same result. (I'm running Windows Vista 64-bit, so that's why I began with WAMP 64-bit). Thank you
  17. I discovered a fix for the disappearing green.... Apply "overflow: hidden" to the parent container. This magically works, but it's kinda stupid because it seems to be a bug. But the green disappearing wasn't really my issue. I want the cards to space themselves like a fluid layout (the space between them changing depending on the browser size), but ALSO allowing them to float next to eachother. Any idea how to achieve this?
  18. Well, I intended the webpage to be able to be any size. The only thing I really wanted to achieve was to have the cards floating AND to have them space themselves out evenly. For instance: When the browser window is large enough for 4 cards to fit horizontally, but not wide enough for 5, I want to see 4 cards side by side, spaced evenly... As far as a floating elements not taking up any space.... weird.
  19. no, sorry. I don't have hosting yet...
  20. I'm trying to make the "playing-cards" space themselves out evenly across the screen horizontally (in the "floor" area). I'm running into problems and have 4 questions about what's going on: Question 1: Where is the green "floor" going? (When I remove the float property from the "playing-cards" it brings back the green "floor" background, but it disappears when I add float to the "playing-cards".) Question 2: When I remove float, why do I still see red above the first card and below the last card? (It seems that the margin from the "playing-card" is ripping a gap between the header and the "floor"... I would expect the margin to simply push the "playing-card" away from the border of it's parent container which is "floor" to produce more green space... but it's not happening that way) Question 3: How do I make the "playing-cards" space themselves evenly on each row? (I thought making left and right margins "auto" and making the position "relative" was supposed to produce this effect, but it's not working out) Question 4: How do I center that text vertically on the first card? <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style type="text/css"> /* complete and total reset */ * { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; line-height: 1.5em; text-decoration: none;} /* end of complete and total reset */ #container { background-color: red;} #header { background-color: blue;} #the-floor { background-color: green;} .playing-card { float:left; border-radius: 10px; overflow: hidden; background-color: white; height: 350px; width: 250px; display: block; margin-top: 25px; margin-right: auto; margin-bottom: 25px; margin-left: auto; position: relative;} p { text-align: center; background-color: yellow;} .playing-card p { vertical-align:middle; height: 100%;} #footer { clear:both; background-color: pink;} </style> </head> <body> <div id="container"> <div id="header"><p>Here is the Header</p> </div><!--end of header--> <div id="the-floor"> <div class="playing-card"> <p>Here is text (with yellow background) on the first white-playing-card. I want all of the white-playing-cards to float as long as there's room. On each row of cards, I want the cards to space themselves evenly (horizontally). Currently they are only aligning to the left.</p> </div><!--end of first playing-card--> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> <div class="playing-card"></div> </div><!--end of the-floor--> <div id="footer"><p>Here is the Footer</p> </div><!--end of footer--> </div><!--end of container--> </body> </html>
  21. Thank you very much Eric! This works sweet, and if I just replace the text with an image (and adjust the "wrap" div width to the same as the picture) it works great. One more question though... If I want to align that image vertically BUT to the RIGHT, what change do I make? It seems there is a default setting somewhere for horizontal centering that isn't being expressed, but I don't know where that would be to change from "center" to "right".
  22. Thank you very much Eric! This works sweet, and if I just replace the text with an image (and adjust the "wrap" div width to the same as the picture) it works great. One more question though... If I want to align that image vertically BUT to the RIGHT, what change do I make? It seems there is a default setting somewhere for horizontal centering that isn't being expressed, but I don't know where that would be to change from "center" to "right".
  23. I'm a bit confused about the "commented-out" code that I'm learning about in the Killersites tutorials. For instance: <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> I think this code is supposed to allow earlier versions of Internet Explorer to display things correctly. My questions: Are we supposed to leave it commented out??? If so, why? If so, how does the browser react to it if the browser thinks it is only a comment??? If we are NOT supposed to leave it commented out, why was it commented out in the lessons?
  24. I'm trying to center text inside it's parent container. It seems like it should be super easy, but it's been kicking my butt for like 4 hours. What am I missing? I thought "vertical-align: middle" was what I needed, but it's not working. Please.... can someone please help me? Here is the html/css code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>kicking my butt!</title> <style> * { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; line-height: 1.5em; text-decoration: none;} header { background-color:#C00;} .header-middle h1 { height: 400px; vertical-align:middle; text-align: center; font-size: 36px; font-family: Verdana, Geneva, sans-serif; color: #0F0; background-color: #000; overflow: hidden;} </style> </head> <body> <header> <div class="header-middle"> <h1>Text to be centered vertically within the black box, but don't know how...</h1> </div><!--end of header-middle div--> </header> </body> </html>
×
×
  • Create New...