Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Also, is the regular expression necessary for creating the link? You could just utilize the URL which is already in a separate variable. <?php $_POST['website'] = trim($_POST['website']); echo "website is <a href='{$_POST['website']}'>{$_POST['website']}</a>"; ?>
  2. Note that variables won't work within single quoted strings. <?php ...'<a href="$0">$input</a>'... ?>
  3. Note that you should validate the number before running the query to prevent SQL injections. If the validation fails, show an error message and avoid running the query. For example, you can make sure you have a number by doing something like the following: <?php $_GET['number'] = trim($_GET['number']); if(!ctype_digit((string)$_GET['number'])) { echo 'Unknown number'; exit(); } ?>
  4. No problem. Note that the following checkbox isn't being added to the array: <input type="checkbox" name="help" id="acting" value="Acting">Acting<br> You need the square brackets after the name.
  5. The way the checkboxes are being named creates an array. To get the values out of the array and into the e-mail, you could use implode(): http://php.net/manual/en/function.implode.php
  6. Are all of your pages built from a single script? It might help if you provide more information on what you're looking to accomplish. It might also help if you have some sample code to show.
  7. That ($niz[]) should give you an array. To see for yourself, you could temporarily add the following line of code after the while loop: <?php echo '<pre>' . print_r($niz, true) . '</pre>'; ?> From there you should look into array_reverse(): http://php.net/manual/en/function.array-reverse.php ...and the return statement: http://php.net/manual/en/function.return.php
  8. What code did you try? We may be able to help you better by seeing the code.
  9. It sure can. Note that the PHP code which generates the page title needs to appear before the <title> tag.
  10. If you don't need a loop, you could also do something like this: <?php $numbers = range(1, 30); print implode('<br>', $numbers); print '<br>'; $numbers = array_reverse($numbers); print implode('<br>', $numbers); ?> An example of using range() in a foreach loop can be found here: http://php.net/manual/en/function.range.php
  11. For adding values to an array, take a look at the "Creating/modifying with square bracket syntax" section found here: http://php.net/manual/en/language.types.array.php The section is right after example 7.
  12. I just re-read the post. The GET variable needs to be added to the form tag as boompa suggested. <?php echo "<form action='update2.php?id={$row['id']}' method='post'>"; ?> Of course, $row['id'] would need to be changed to whatever variable you're using within the form script.
  13. When update2.php was called, did you pass the id variable? For example: ...update2.php?id=3
  14. It looks like all the radio buttons are named "radio". Try clicking "Dog" on your form and then click "Email me". Note that "Dog" is no longer selected. You may want to review the following: http://www.tizag.com/htmlT/htmlradio.php Whatever you change the names to is what you would use for the $_REQUEST variables. Side note: I would also recommend the <label> tag: http://www.cyberscorpion.com/2012-02/making-html-forms-more-accessible-and-improving-usability-with-the-label-tag/
  15. Yep, double quotes can't be used within double quotes unless they are escaped. You can also switch the quote types. For example <?php //... $homeimage = '<a href="index.php" border="0"><img src="menu_home_open.jpg"></a>'; //<-- the outside quotes were changed to single quotes //... ?> More information about using quotes with strings can be found here: http://php.net/manual/en/language.types.string.php
  16. Could you provide a little more information by what is meant by "...print the one item from each group..."? Are you looking to display what was submitted through the form on the Thank You page? If so, the form information needs to be passed to the Thank You page. Some solutions for passing data through the header redirect can be found here: http://stackoverflow.com/questions/11803343/how-to-pass-variables-received-in-get-string-through-a-php-header-redirect
  17. Are you just looking for feedback on best practices...or is something not working? Note that you'll want to review the quotes within the code. In some cases, you have double quotes within double quotes. Later, there is a variable within single quotes...which won't work. For what it's worth, using if statements should work just fine. You could, however, limit the number times you write $menuopen by using switch() instead: http://php.net/manual/en/control-structures.switch.php
  18. Have you considered using a third-party alternative? Google forms, for example, are free and can be embedded within an existing website. https://support.google.com/drive/answer/87809?hl=en JotForm is another nice option. They have a free service plan and can be embedded. http://www.jotform.com/ If you still want to build your own form (or download one from the Web), be mindful that there are risks. For example, online forms will likely be targeted for injection attacks. If you're interested, there are many tips online for avoiding e-mail injection: https://www.google.com/search?q=email+injection+php Note that I didn't download your code, so perhaps this is already taken care of.
  19. First, you'll need to recheck the double quotes in the if statements. Afterwards, the following link may help: http://www.sitepoint.com/forums/showthread.php?571957-quot-dynamic-quot-i-variable-names-in-javascript
  20. It's difficult to tell what's going on since code doesn't have any line breaks. One issue that I noticed, however, is that the following has an unescaped double quote: <form action=\"action.php" method=\"post\" I'm not sure if that would cause the problem you describe though...
  21. Have you looked into clearInterval()? https://developer.mozilla.org/en-US/docs/Web/API/window.clearInterval
  22. It might help to have a description of the problem. What is it doing that you don't expect?
  23. Try adding a few var_dump() calls: <?php $tmp = "mystring1".$mylink."mystring2"; var_dump($tmp); print '<br>'; $final_link = urlencode($tmp); var_dump($final_link); print '<br>'; $loc = "Location: ". $final_link; var_dump($loc); print '<br>'; ?> What does each call return?
  24. Perhaps this helps: http://stackoverflow.com/questions/6551106/change-to-php-ini-does-not-have-effect If not, have you tried date_default_timezone_set() http://php.net/manual/en/function.date-default-timezone-set.php
  25. So basically, you're looking for suggestions on how to improve the look of HTML tables? If so, are you familiar with CSS? Note: there are many tutorials online for stylizing HTML tables with CSS: https://www.google.com/search?q=css+tables
×
×
  • 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.