IntraNet ![]() ![]() |
PHP | Manual |
Get all submitted variables | /* DEBUG */ <pre> <?php print_r($_REQUEST); ?> </pre> |
Get php info | To test your PHP setup is pretty simple, create a file called test.php
in your web browseable directory into which put the following contents:
<?PHP |
Table Lock | When I am concerned about the ID, I always lock the table first, then release it when I have the ID:
lock tables AH_Annotation That should do it. Add in the $link_id, too, for best results. |
$_POST[salutation] | When inside double quotes, it doesn't parse variables that use single quotes without an error. So you have to leave off the single quotes:
<?php print htmlentities ( "$_POST[salutation] $_POST[firstname] $_POST[lastname]" ); ?> The purpose for using the single quotes is to distinguish the index name as such, and not a defined constant. If you do this: $var = $_POST[var]; It thinks the var referred to on the right side of the equation as a constant, but if you do this: $var = $_POST['var']; It knows it's an array index name. Inside double quotes, it won't think it's a constant, since it doesn't look for constants inside double quotes. |
Retrieve single records | It makes for cleaner code, and easier tracking, if instead of this:
$db->next_record($dbstatus); You do $db->next_record($dbstatus); Then reference using: $rs['shortname'] |
require in functions | Make sure that any time you need the variables in globals.txt you include them inside the function. This will be okay: require 'globals.txt'; If there is one require and one require_once, then it probably won't load the |
Session destroy as in logout | session_destroy(); <- deletes the session file, where the info is stored session_unset(); <- deletes the $_SESSION variable and removes cookie |
Origin of a message | "This message was generated by http://$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]" |
The effect of seeing bounces at a given address is controlled by the envelope sender, and that by default is the username @ the system's name, so that's where apache@www.spallek.net enters the picture. To set the envelope sender, you typically need to use "-f<address>" when calling sendmail. php's mail() function can take a fifth argument which will be passed to sendmail, so you could try adding it there.
Your mail() call might then look like this: mail("$PAEmail", "My DOG: Mitgliedsbeitrag Zahlungsart", $message, "From: mitgliedsbeitrag@dog.org\nReply-To: mitgliedsbeitrag@dog.org", "-fmitgliedsbeitrag@dog.org"); |
|
MySQL Timestamp to Date | ... UNIX_TIMESTAMP(lastupdate) AS lastupdate ... $lastupdate = strftime ("%d.%m.%Y", $lastupdate); |
Debug for flow | define('DEBUG', 0);
<?php if ( DEBUG ) |
run from console | with `php -l -f <file.php>'. The -l sais not to run it, but to check the syntax only. |
Form Confirm (escape user input) | $access = $db->query ("update FreeVisSurvey2005 set antwort='" .mysql_escape_string($_REQUEST['antwort'])."', |