Jump to content

alpine

Members
  • Posts

    759
  • Joined

  • Last visited

Everything posted by alpine

  1. Missing php closing tag on the bottom: ?>
  2. You should probably also convert periods (.) and dont rely on everyone using commas In addition i would remove whitespace etc. $text = trim(str_replace(array(",","."), "", $text));
  3. The variables from POST does not match the one used in email body, example: $apt1Field is declared from POST apt1 while inside email body it looks for variable $apt1 /* Information Variables */ $monthField = $_POST['month']; $apt1Field = $_POST['apt1']; $apt2Field = $_POST['apt2']; $apt3Field = $_POST['apt3']; $apt4Field = $_POST['apt4']; $apt5Field = $_POST['apt5']; $apt6Field = $_POST['apt6']; $totalField = $_POST['total']; $fromField = $_POST['from']; $body = <<<EOD <br /><hr /><br /> Email: $month <br /> 708 Front St: $apt1 <br /> 708 1/2 Front St: $apt2 <br /> 218 N. Park Ave: $apt3 <br /> 220 N. Park Ave: $apt4 <br /> 1236 Sycamore St: $apt5 <br /> 1236 1/2 Sycamore St: $apt6 <br /> Total: $total <br /> From: $from <br /> EOD;
  4. I would go for an AJAX aproach, adding picked boxes in a db by a php backend file - if done with pure php you must have each click reloading the page adding up the picked boxes in a session array or to db. Another variant is ofcourse to use javascript adding picked boxes either to a cookie or collecting all div id's in a hidden textfield that is treated by php on submitting the result page. im sure there are many ways of doing it, i would go for the AJAX method.
  5. Play around with these examples $random1 = RandomFile("random"); $random1 = RandomFile("dir/myfolder"); $random1 = RandomFile("../path/to/myfolder");
  6. I suspect you might be looking for something like this (simplified example) <?php // img_src.php $id = $_GET['id']; // make GET id db safe // query db for filename, content type and path based on requested photo id header('Content-Type: image/jpeg'); echo file_get_contents('path/to/file/filename.jpg') ?> Then call img_get.php for each photo like this to display it <img src="img_src.php?id=foo" />
  7. It was an error on ending the heredoc syntax, but moving ; one line below is not the problem - adding space like this fixed it (showing from line 103) </tr> </table> </body> </html> EOD; echo $theResults; When that is said you dont need to run all this html through heredoc since you arent filling in any php variables at all as far as i can see *edit* EOD without space in front of it, shows poorly in the code block on this forum Also i recoment creating a better description rather than "Help Needed" etc when creating forum topics - most topics are created because the topic starter needs help.
  8. <?php $fields = array( 'First_Name' => 'First Name', 'Last_Name' => 'Last Name', 'Card' => 'Card Number', 'Old_Card' => 'Old Card Number' // and so on ); $body = "We have received the following information from $_SESSION[username]:\n\n"; foreach($_REQUEST as $a => $b){ if(array_key_exists($a, $fields) && !empty($b)){ $part1 .= sprintf("%20s: %s\n", $fields[$a], $b); } } ?>
  9. <?php $data = "ABCDEF"; if(substr($data,0,3) == "ABC") ?>
  10. look at http://www.php.net/manual/en/function.file-get-contents.php But if the server where the file is does not respond you cannot read it
  11. You need a total results to do this easily, example <?php $i = 1; while ($i <= 10) { $i++; if($i <> 10) echo "<hr>"; } ?>
  12. It is no problem to show the form again after it is submitted if an error exists, post form to the same file as you have the form and fill the form with the posted variables. Example: <?php $complete = false; $empty_arr = array(); foreach($_POST as $fieldname => $fieldvalue) { if(empty($fieldvalue)) { $empty_arr[] = $fieldname." was left empty"; } ${$fieldname} = $_POST[$fieldname]; } if(!empty($empty_arr)) { echo "<ul><li>"; echo implode($empty_arr, '</li><li>'); echo "</li><ul>"; } else { // no empty fields, prosess posted values already defined as $fielnames $complete = true; } if($complete == false) { echo <<<_HTML <form method="post" action="{$_SERVER['PHP_SELF']}"> <p>Name:<br /><input type="text" name="name" value="$name" /></p> <p>Email:<br /><input type="text" name="email" value="$email" /></p> <p><input type="submit" name="submit" value="Send" /></p> </form> _HTML; } ?> When you mention instant red border on error fields that is mainly pure javascript validation, one example is http://www.formassembly.com/wForms/
  13. $_GET, $_POST and $_REQUEST are all predefined variables, and returns empty if not set - and empty array "array()" is considered valid empty using empty()
  14. I prefer to expect variable either as POST or GET and try to avoid the possibility for both, if you however expect both you could use REQUEST <?php if(empty($_REQUEST['var'])) ?> as empty returns false also if 'var' is not set, so it checks both if it is set and that its not empty
  15. I would never rely on javascript alone as this is easily manipulated if someone want to do so, you should always validate with php. AJAX is my preferred method if validating along the form since i can ask the same php functions both times.
  16. You can start with this <?php function Check($data){ // this example allowing: A to Z a to z 0 to 9 . , space(s) - @ _ if(preg_match("/^[-A-Za-z0-9.,\s@_]+$/", $data)) return true; else return false; } if(!Check($_POST['text'])){ echo "Illegal input found"; } ?>
  17. Work with something like this <?php $input = "a:10 b:20 c:30 a:50 b:60 c:70 a:150 b:160 c:170"; preg_match_all('/c:(\d+)/',$input,$out); $out = array_reverse($out); while(list($key, $val) = each($out[0])){ ${$key} = $val; } ?>
  18. Its better to use a switch statement tho <?php switch($_GET['page']){ case 'home': // include or whatever on home break; case 'news': // include or whatever on news break; default: // include or whatever when $_GET['page'] doesnt match other case, or dont exist } ?>
  19. Not sure i fully understand what you are doing, but look at <?php $values = array("Double-Glazing" => 3, "test" => 1, "test2" => 1, "test5" => 7); rsort($values); echo $values[0]; // 7 ?>
  20. another variant <?php $test = 'this is a test string'; echo implode(" ", array_slice(str_word_count($test, 1), 0, -1)); // this is a test ?>
  21. Then you have no post data from your form - for some reason
  22. add this on top of your script to debug whats posted and whats not, replace with $_GET to debug get variables echo "<pre>"; print_r($_POST); echo "</pre>";
  23. Check out http://www.php.net/manual/en/function.mcrypt-encrypt.php and http://www.php.net/manual/en/function.mcrypt-decrypt.php
  24. You cannot open the standard browse window on a server location, you have to make your own file browse window. Look into http://no.php.net/manual/en/function.readdir.php - there is som user examples you can start with. Then you will have to use javascript in one way or another (easiest) to move filenames between browse window and form.
×
×
  • 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.