Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Would this work? $ids = implode(",", array_map('intval', $_POST['m'])); Yes. I literally just posted that exact code but you already did.
  2. You should be doing this from a POST request, not GET. Then you could tag an alert onto the form. Then do something like... <form action="" method="post" onsubmit="return confirm('Are you sure?');"> <input type="hidden" name="id" value="1" /> <input type="submit" name="submit" value="Delete" /> </form>
  3. I can't view your links because I think I need to log in or something (can't read whatever language it is in). So can you post the full HTML source (from the browser) of each page?
  4. Regular expressions. <?php $str = '<b><font color=green>Get me out please </font>.</b>'; $pattern = '/<font[^>.]*>(.*)<\/font>/i'; if (preg_match($pattern, $str, $matches)) { echo $matches[1]; // Get me out please } Also, don't bump your threads after 2 hours.
  5. If you want the form to land on the same page it was displayed on, you can simply leave the action blank.
  6. Try: $action = isset($_GET['action']) ? $_GET['action'] : ''; switch($action) { ...
  7. And if "a1" wasn't set you would get an undefined index error with that code. If the checkbox isn't checked and you submit the form, you won't get any $_POST data at all about that checkbox. So simply checking if the $_POST value exists is enough to know if the checkbox was checked or not. You can do that with if (isset($_POST['a1'])) ... You can turn the checkboxes into an array, and then you can figure out how many of them there are. For example... <?php if (!empty($_POST)) { $users = isset($_POST['user']) ? $_POST['user'] : array(); foreach(array_keys($users) as $key) { echo 'User "' . $key . '" is set!<br />'; } } ?> <form action="" method="post"> <input type="checkbox" name="user[a1]" value="1"> <input type="checkbox" name="user[a2]" value="1"> <input type="checkbox" name="user[a3]" value="1"> <input type="checkbox" name="user[a4]" value="1"> <input type="submit" name="submit" value="submit" /> </form>
  8. Huh? I don't really understand what you are asking, but you can check if checkboxes are checked in this way: <?php if (!empty($_POST)) { $check = isset($_POST['check']) ? (bool) $_POST['check'] : false; var_dump($check); } ?> <form action="" method="post"> <input type="checkbox" name="check" value="1"> <input type="submit" name="submit" value="submit" /> </form> $check will either be "true" if it is checked, or "false" if it isn't.
  9. You shouldn't use a header redirect, because then all of the form data would be lost. If you process the form on the same page as you display it, this task is trivial. This codes a bit ugly but it should give you an idea of the process: <?php // check if the form was submitted if (!empty($_POST)) { // set an array of required fields to check $required = array('firstname', 'lastname'); $errors = array(); // loop through the required fields and make sure they are not empty foreach($required as $key) { if (empty($_POST[$key])) { // populate the errors array if a required field is empty $errors[$key] = 'This field is required'; } } // if no errors were found, continue processing the script if (empty($errors)) { header('location: http://example.com'); exit; } // if there are errors, the form will be redisplayed } echo '<form action="" method="post"> First Name: <input type="text" name="firstname" value="' . (isset($_POST['firstname']) ? $_POST['firstname'] : '') . '" /><br /> ' . (isset($errors['firstname']) ? $errors['firstname'] . '<br />' : '') . ' Last Name: <input type="text" name="lastname" value="' . (isset($_POST['lastname']) ? $_POST['lastname'] : '') . '" /><br /> ' . (isset($errors['lastname']) ? $errors['lastname'] . '<br />' : '') . ' <input type="submit" name="submit" value="Submit" /> </form>';
  10. If you want to do that without a page refresh you're going to have to use AJAX to dynamically load in the new content.
  11. http://us3.php.net/manual/en/function.mail.php You can use the implode function to condense an array into a string with separators. So this means you can take an array of emails (like what you would have if you got them from a database) and turn them into a string separated by commas which you can then plop into the mail function.
  12. That's more jail time than most real crimes get. That's pretty ridiculous.
  13. In the "to" parameter of the mail() function, you can separate emails with a comma to send multiple emails.
  14. array_unique won't work from inside the while loop, since it's only getting one row at a time. Is it actually duplicating rows or do you just have more than one row with the same content? If the latter, you should be able to, on each iteration, add the link to an array. Then on at the start of the loop, check if the current link already exists in the array. If it does, use continue to stop the loop and go to the next post.
  15. You'll have to modify the have_posts() function to not fetch duplicates. Or, modify the code that saves the data to not save duplicates.
  16. You either need to concatenate the variables in the single quotes, $address = $addressL1 . ',' . $area . ',' . $county . ',' . $postcode . ',' . $country; Or use double quotes $address = "$addressL1, $area, $county, $postcode, $country";
  17. You do, but not constants.
  18. echo isset($_GET['failed']) ? CTN_TXT_MYERRORMESSAGE : ''; With the ternary operator, it goes condition ? if condition is true : if condition is false;
  19. What does the query look like when you print it out?
  20. So you basically want to recreate Dropbox?
  21. You could maybe use a session to keep the data.
  22. You'll need to escape the single quotes. So this should work: fwrite($newhtml, ' <?php while($row = mysql_fetch_array($result_date)){ $date = $row[\'1\']; $team1 = $row[\'2\']; $team2 = $row[\'3\']; ?> ');
  23. So then buy a wireless router.
  24. If you're on linux you can use Samba to mount a remote location.
  25. What are the errors?
×
×
  • 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.