Jump to content

noXstyle

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Everything posted by noXstyle

  1. Hi, Domain masking ain't the right term to use for sure. Well, you can if you change the link to a form and send the data using POST. In that case the url can be whatever you like since you're sending the mission critical data behind the curtains. Also that is one hell of a url since you send the product descriptions and stuff. Since you probably have the product data in database why not fetch it by only sending the product id? In that case you would only have to do: <a href="product.php?id=<?php echo $row['id']; ?>" class='productlink' rel="nofollow" ><?php echo $row['description']; ?></a> And you were concerned about SEO. In that case you might want to use use mod_rewrite to rewrite the urls to: product/product-name If you have unique product names you can fetch the product from database based on the name given. In real life it is rather poor implementation and i would suggest passing the id anyway. If you don't want the id to appear on url make a form and pass it via post. Hope I'm making any sense.
  2. Oh sh*t, yeah sorry.. I was wrong here. To be honest, the idea of somebody storing security related data as included variables didn't even cross my mind. Thank you PFMaBiSmAd for straightening this out. I was going to run an escape loop through the post superglobal but couldn't be arsed to change the variable names.
  3. Ok, so yea now you got it all wrong... Line: if (!mysql_query ($firstname && $lastname && $address && $state && $city)) { doesn't do anything. When you insert data you do mysql_query($sql). Also that checks if mysql_query() fails. And it does indeed without proper query. My suggestion to your code would be: <?php include('init.php'); foreach($_POST as $k=>$v) ${$k} = mysql_real_escape_string($v); if (!empty($firstname) && !empty($lastname) && !empty($address) && !empty($state) && !empty($city)) { $sql="INSERT INTO customers (first_name, last_name, address, state, city) VALUES('$firstname','$lastname','$address','$state','$city')"; if(!mysql_query($sql)) echo 'Error while inserting data to database'; else // no empty values and database insert was successful, output success message or something } else echo "You must fill the entire form!";
  4. Ok, whats the problem here? I just get text saying '1 record added' when filling the form. Did you fix this already? And yeah, you might want to do the sql insert only if the form is filled. Also you could loop the $_POST variables instead of manually assigning them: foreach($_POST as $k=>$v) ${$k} = mysql_real_escape_string($v);
  5. Update to my previous post: If you're still looking for the bolded price, the following code actually gets you the results: $goldPrice = (float)$html->find('#pricing_goldCurrent table tbody tr td', 1)->plaintext; And what comes to the server error: I was working with simple html dom with a server that had file_get_contents() disabled, so i had to replace the content loading mechanism. Obviously this is not the case since you can run regex on the content. The library is pain in the ass in a sense that it fills up the memory freakishly easily and as a result you just get a boring 500 internal server error. And the best solution i came up with is to debug step by step the freaking code. Fortunately clear() function frees up all unused stuff real nicely. The previous code i supplied caused some sort of loop and raised an error since it didn't return an object. This might be one of the reasons for server error. If you decide to stick with the library, try to var_dump the $html you loaded and see do you get anything out of it. If you do the code above will get the price for you. And yeah like CPD mentioned regex works too, but it tends to complicate things more than necessary. I was trying to make a case against regex and it's extensibility in this context but couldn't come up with anything. Fair enough.
  6. Hmm... About the HTML markup: echo'<input type="hidden" name="id" value='.$id.'>'; Should be echo'<input type="hidden" name="id" value="'.$id.'">'; Also the last part is unnecessary on line: echo"<b>name:</b>".$record->name." <b>Price: </b>".$record->price.""; Should be: echo"<b>name:</b>".$record->name." <b>Price: </b>".$record->price; Make sure the form targets are correct. You show a form with action to home.php and give us error from shop.php. Which form targets to shop.php? Undefined index notice will get risen when you are trying to access array key that is not specified. In this instance you are posting data and trying to access id key, which was not present on the form you submitted. Just make sure you are submitting the right form to the right place and you should be golden.
  7. Hi JohnS! Take a look at Simple HTML DOM parser. Basically you can get the gold value by using: $html = file_get_html('http://www.lbma.org.uk/pages/index.cfm?page_id=46&title=current_statistics'); $element = $html->find('#pricing_goldCurrent table tbody tr td')->children(1); $goldValue = (float)$element->plaintext; If that doesn't work try out descending from the div id 'pricing_goldCurrent'. Simple HTML DOM also has an adequate documentation to get you well on your way.
  8. Check out simpleXML: http://php.net/manual/en/book.simplexml.php http://www.php.net/manual/en/simplexml.examples-basic.php Makes your job so much easier.
  9. varchar is fine. Do a var_dump() on the price field and see what it outputs. One tip though: It is way more convenient to save a price (since you're dealing with prices) as a numeric value to database. And then when you get the data you would echo it like: echo 'price="' . $row['price'] . ' £" '; So my suggestion is you make the type of price field as FLOAT or DOUBLE and append the pound sign to the price while outputting the data. That way you can do calculations with the price if needed in the future without processing the fields with php.
  10. Hi, Just to pitch in here: you don't necessarily need captcha to prevent spam. What I usually do is: 1. Give a random name (e.g. kifer32w39) to email field. Validate this field as email. 2. Create email field and hide it. When the form is submitted check that this field is not filled. If it is, don't submit the form. Pretty efficient against spam bots since most of them fill out most used email field names. Of course this doesn't eliminate manual spam, nor does captcha for that matter.
  11. No. You save the pound sign as £ to database which is html entity equivalent to £. When you output the data from database the £ will automatically be converted to £.
  12. Save the pound sign as £ to database. For example if you are saving input to database you would replace the pound sign like: $input = str_replace('£', '£', $input);
  13. Hi. Can you try to be a bit more specific? Or try to express yourself a bit more clearly? The way I understood this is that you are trying to create a view counter for videos. Am I correct? Or are you trying to get the amount of views a specific person has viewed a single video? Anyway: what your code does it increments the counter each time the code block is executed. If you want to get the views for specific videos you should for example assign a video ID or something similar to the view array. $views = $_SESSION['views'][videoID']++; In that way it increments the counter for a specific video, when user views another video another video ID is being incremented. In case you want to get the total views, you should increment database view counts rather than session values. Hope this makes any sense.
  14. True. Or you could just return the output of the number_format: // return number_format($shippingCost,2); //
  15. hi, zend has neat validation libraries, so does CI and you can browse the code directly on github. c'mon now, it's not that hard to find a email validation function. but anyways, try: preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", $e); Edit: hmm wait a sec, your regex is identical to mine. apart from the domain length... which email are you trying to validate? if you have a domain like .info your regex will return false since it accepts only 3 chars to the extension.
  16. I'm truly not an expert on this subject, but here's my take anyway: If you are using a php script to send out those mails, php's mail -function will return true/false based on whether the mail has been accepted for delivery. That's about it. You can try to add headers like: $headers .= "Errors-To: youremail@mail.com\r\n" $headers .= "Return-Path: youremail@mail.com\r\n"; which should route the bounced mails to the specified address. It is up to you to figure out how you can parse the bounced mails and get the required info. That's just not possible. At least I hope it's not. Imagine a world where spammers know how to get past your spam filters.
  17. Do you want to print the whole result again or only access parts of it? If I understood you correctly, creata.physics already answered your question. For instance you would just append to a variable: $output = ''; // don't forget to initialize the variable, otherwise php will throw a notice when appending rows to it while($row = mysql_fetch_array($result)) { $output .= "Your html here\n"; } Other way is to store the table rows you create in an array: while($row = mysql_fetch_array($result)) { $output[] = "Your html here\n"; } If you need to access a single row later on, you might probably want to assign row id's as the array keys or something similar. And if you want to output the whole content you can always implode the array thus giving you the whole row set.
  18. What do you mean by 'passed too many parameters' ? He is passing a comma as the glue and $category as the array. Unfortunately the $cateagory is not an array at this instance. You probably want to check that the $category actually holds an array: elseif ($type == 'cat') { if(isset($category) && is_array($category)) $postsq = implode(",",$category); } And if this breaks functionality, you should debug the code and see where the $category actually comes from and why it is not an array.
  19. Hello there, As for the subject: strpos does accept whitespaces. your substr's length parameter is just wrong since you're getting the length from the whole string. Anyways, my version of the function: function get_between($input, $start, $end) { $start = substr($input, strpos($input,$start) + strlen($start)); return substr($start, 0, strpos($start, $end)); } Should work just neatly. There's also a better way to get the content between two clues: function get_between($content,$start,$end){ $r = explode($start, $content); if (isset($r[1])){ $r = explode($end, $r[1]); return $r[0]; } return ''; } Hope this helps.
  20. I'm guessing that Paypal IPN is the thing you're looking for. The way it works is that paypal sends the payment status to your ipn listener rather than via user session params. You can find premade php classes to do the actual heavy lifting for you, like the one hosted in google code.
  21. Yes. Shouldn't you like try before asking here? If it doesn't work you can always fix it . And zend has probably the best documentation out there, learn to use it. You will need it sooner or later.
  22. What you mean? The latter one displays just fine. Just add some styles and you'll have a similar table as shown on the picture. You could also use another table for the ingredients, like: <table border="1"> <tr> <th>Sushi</th> <th colspan="2">Ingredients</th> </tr> <?php foreach($sushi as $k=>$v):?> <tr> <td><?php echo $k?></td> <td> <table border="1" width="100%"> <?php foreach($v as $k2=>$v2):?> <tr> <td><?php echo $k2; ?></td> <td><?php echo $v2; ?></td> </tr> <?php endforeach; ?> </table> </td> </tr> <?php endforeach; ?> </table> But anyhow, you still cant avoid from styling the table if you want one similar to the picture.
  23. Can you debug the part of the code that is being json encoded? if you have two dimensional array, i.e. array(array('name'=>x,'status'=>x)), you will have to access it differently. You probably can access this kind of data using responseObject[0].name or responseObject[0].status but i think it would be more convenient to get a simple array to the json_encode. In that case it would work in a way you're using it now.
  24. No idea what cooldood just said, but heres your problem: 1. The function is inside User class, therefore you must use $this->generateHash() Btw since the function is same for all instances of the User object you might as well make it static and call it self::generateHash() 2. You cant assign variable reference without variable. Your function definition: function generateHash($password, &$saluti=null) Your call: $this->generateHash($password,'') This will return fatal error. Either remove the variable reference tag (&) or pass a variable to the function.
  25. <?php function getMax($a) { $max = array_keys($a, max($a)); if(count($max)>1) { $r = rand(0, count($max)-1); return array($max[$r] => $a[$max[$r]]); } return array($max[0]=>$a[$max[0]]); } Will return array in which the key is option_id and value is number of votes. Edit: You can also simplify the function by removing the if statement. In this case there will be a rand() call even if a single max value is found. function getMax($a) { $max = array_keys($a, max($a)); $r = rand(0, count($max)-1); return array($max[$r] => $a[$max[$r]]); }
×
×
  • 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.