This topic is locked
[SOLVED]

 like this now in the script of PHPrunner erstelleten racks

6/24/2009 6:07:51 AM
PHPRunner General questions
T
taroma7273 author

Hello to all PHP kings!
I am still a beginner and need help with the following Porblem.
I already have what I want in a PHP script, and he also works but I would like this now in the script of PHPrunner erstelleten racks.
Weis is not where I put my query with anschließsenden insert SLQ results so that they will be processed correctly.
I hope you can follow me. attached when the scripts are, please ask me I will write all the info you need even
more later many thanks in advance for your efforts.
[codebox]

<?php
if (isset($_POST["gesendet"]) and ($_POST["gruppe"] == "HR" and ($_POST["TITER"] >= "100" and($_POST["NAME"] == "Titerbestimmung"))))

{
mysql_connect("","root");

mysql_select_db("BMI");
$sqlab = "INSERT INTO `bmi`.`impfdaten` (`zeitstempel`, `SVNR`, `NAME`,`FOLGENAME`, `DATUM`, `TITER`, `ANMERKUNGEN`, `FOLGETERMIN`) VALUES (NOW(), '" . $_POST["SVNR"] . "', '" . $_POST["NAME"] . "','Titerbestimmung', '" . $_POST["DATUM"] . "', '" . $_POST["TITER"] . "', '" . $_POST["ANMERKUNGEN"] . "',NOW()+ INTERVAL 10 YEAR)";
mysql_query($sqlab);
$num = mysql_affected_rows();
if ($num>0)

{

echo "<font color='#00aa00'>";

echo "Es wurde 1 Datensatz hinzugefügt<p>";

echo "</font>";

}

else

{

echo "<font color='#ff0000'>";

echo "Es ist ein Fehler aufgetreten, ";

echo "es wurde kein Datensatz hinzugefügt<p>";

echo "</font>";

}

}

if(isset($_POST["gesendet"]) and ($_POST["gruppe"] == "HR" and ($_POST["TITER"] >= "20" and ($_POST["TITER"] <="99" and ($_POST["NAME"] == "Titerbestimmung")))))

{
mysql_connect("","root");

mysql_select_db("BMI");
$sqlab = "INSERT INTO `bmi`.`impfdaten` (`zeitstempel`, `SVNR`, `NAME`, `DATUM`, `TITER`, `ANMERKUNGEN`, `FOLGETERMIN`) VALUES (NOW(), '" . $_POST["SVNR"] . "', '" . $_POST["NAME"] . "', '" . $_POST["DATUM"] . "', '" . $_POST["TITER"] . "', '" . $_POST["ANMERKUNGEN"] . "',NOW()+ INTERVAL 6 MONTH)";
mysql_query($sqlab);
$num = mysql_affected_rows();

if ($num>0)

{

echo "<font color='#00aa00'>";

echo "Es wurde 1 Datensatz hinzugefügt<p>";

echo "</font>";

}

else

{

echo "<font color='#ff0000'>";

echo "Es ist ein Fehler aufgetreten, ";

echo "es wurde kein Datensatz hinzugefügt<p>";

echo "</font>";

}

}

if(isset($_POST["gesendet"]) and ($_POST["gruppe"] == "HR" and ($_POST["TITER"] >= "0" and ($_POST["TITER"] <="19" and ($_POST["NAME"] == "Titerbestimmung")))))

{
mysql_connect("","root");

mysql_select_db("BMI");
$sqlab = "INSERT INTO `bmi`.`impfdaten` (`zeitstempel`, `SVNR`, `NAME`, `DATUM`, `TITER`, `ANMERKUNGEN`, `FOLGETERMIN`) VALUES (NOW(), '" . $_POST["SVNR"] . "', '" . $_POST["NAME"] . "', '" . $_POST["DATUM"] . "', '" . $_POST["TITER"] . "', '" . $_POST["ANMERKUNGEN"] . "',NOW())";
mysql_query($sqlab);
$num = mysql_affected_rows();

if ($num>0)

{

echo "<font color='#00aa00'>";

echo "Es wurde 1 Datensatz hinzugefügt<p>";

echo "</font>";

}

else

{

echo "<font color='#ff0000'>";

echo "Es ist ein Fehler aufgetreten, ";

echo "es wurde kein Datensatz hinzugefügt<p>";

echo "</font>";

}

}
?>
[/codebox]

[codebox]
// processing Abfrage folgetermin -start here where it is purely and here I have already inserted from
<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

set_magic_quotes_runtime(0);
include("include/dbcommon.php");

include("include/impfdaten_variables.php");
// check if logged in
if(!@$_SESSION["UserID"] || !CheckSecurity(@$SESSION["".$strTableName."_OwnerID"],"Add"))

{

$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return;

}
$filename="";

$status="";

$message="";

$usermessage="";

$error_happened=false;

$readavalues=false;
$showKeys = array();

$showValues = array();

$showRawValues = array();

$showFields = array();

$showDetailKeys = array();

$IsSaved = false;

$HaveData = true;
if(@$_REQUEST["editType"]=="inline")

$inlineedit=ADD_INLINE;

elseif(@$_REQUEST["editType"]=="onthefly")

$inlineedit=ADD_ONTHEFLY;

else

$inlineedit=ADD_SIMPLE;

$keys=array();

if($inlineedit==ADD_INLINE)

$templatefile = "impfdaten_inline_add.htm";

else

$templatefile = "impfdaten_add.htm";
$id=postvalue("id");
//connect database

$conn = db_connect();
// Before Process event

if(function_exists("BeforeProcessAdd"))

BeforeProcessAdd($conn);
include('libs/xtempl.php');

$xt = new Xtempl();
// insert new record if we have to
if(@$_POST["a"]=="added")

{

$afilename_values=array();

$avalues=array();

$files_move=array();

$files_save=array();

// processing GRUPPE - start

if($inlineedit!=ADD_INLINE)

{

$value = postvalue("value_GRUPPE");

$type=postvalue("type_GRUPPE");

if (in_assoc_array("type_GRUPPE",$_POST) || in_assoc_array("value_GRUPPE",$_POST) || in_assoc_array("value_GRUPPE",$_FILES))

{

$value=prepare_for_db("GRUPPE",$value,$type);

}

else

$value=false;

if(!($value===false))

{
$avalues["GRUPPE"]=$value;

}

}

// processibng GRUPPE - end

// processing SVNR - start

if($inlineedit!=ADD_INLINE)

{

$value = postvalue("value_SVNR");

$type=postvalue("type_SVNR");

if (in_assoc_array("type_SVNR",$_POST) || in_assoc_array("value_SVNR",$_POST) || in_assoc_array("value_SVNR",$_FILES))

{

$value=prepare_for_db("SVNR",$value,$type);

}

else

$value=false;

if(!($value===false))

{
$avalues["SVNR"]=$value;

}

}

// processibng SVNR - end

// processing NAME - start

if($inlineedit!=ADD_INLINE)

{

$value = postvalue("value_NAME");

$type=postvalue("type_NAME");

if (in_assoc_array("type_NAME",$_POST) || in_assoc_array("value_NAME",$_POST) || in_assoc_array("value_NAME",$_FILES))

{

$value=prepare_for_db("NAME",$value,$type);

}

else

$value=false;

if(!($value===false))

{
$avalues["NAME"]=$value;

}

}

// processibng NAME - end

// processing TITER - start

if($inlineedit!=ADD_INLINE)

{

$value = postvalue("value_TITER");

$type=postvalue("type_TITER");

if (in_assoc_array("type_TITER",$_POST) || in_assoc_array("value_TITER",$_POST) || in_assoc_array("value_TITER",$_FILES))

{

$value=prepare_for_db("TITER",$value,$type);

}

else

$value=false;

if(!($value===false))

{
$avalues["TITER"]=$value;

}

}

// processibng TITER - end

// processing ANMERKUNGEN - start

if($inlineedit!=ADD_INLINE)

{

$value = postvalue("value_ANMERKUNGEN");

$type=postvalue("type_ANMERKUNGEN");

if (in_assoc_array("type_ANMERKUNGEN",$_POST) || in_assoc_array("value_ANMERKUNGEN",$_POST) || in_assoc_array("value_ANMERKUNGEN",$_FILES))

{

$value=prepare_for_db("ANMERKUNGEN",$value,$type);

}

else

$value=false;

if(!($value===false))

{
$avalues["ANMERKUNGEN"]=$value;

}

}

// processibng ANMERKUNGEN - end
// processing Abfrage folgetermin -start

if(isset($_POST["value_GRUPPE"]) == "HR" and ($_POST["value_TITER"] >= "0" and ($_POST["value_TITER"] >= "19" and ($_POST["value_NAME"] == "Titerbestimmung"))))

{

$sqlab = "INSERT INTO `bmi`.`impfdaten` (`FOLGETERMIN`) VALUES (NOW() +

INTERVAL 6 MONTH)";
// processing Abfrage folgetermin -end
// insert masterkey value if exists and if not specified

if(@$_SESSION[$strTableName."_mastertable"]=="personaldaten")

{

$avalues["SVNR"]=prepare_for_db("SVNR",$_SESSION[$strTableName."_masterkey1"]);

}
if($inlineedit==ADD_ONTHEFLY || true)

{

}
// add filenames to values

foreach($afilename_values as $akey=>$value)

$avalues[$akey]=$value;

// make SQL string

$strSQL = "insert into ".AddTableWrappers($strOriginalTableName)." ";

$strFields="(";

$strValues="(";
// before Add event

$retval = true;

if(function_exists("BeforeAdd"))

$retval=BeforeAdd($avalues,$usermessage,$inlineedit);

if($retval)

{

foreach($avalues as $akey=>$value)

{

$strFields.=AddFieldWrappers($akey).", ";

$strValues.=add_db_quotes($akey,$value).", ";

}

if(substr($strFields,-2)==", ")

$strFields=substr($strFields,0,strlen($strFields)-2);

if(substr($strValues,-2)==", ")

$strValues=substr($strValues,0,strlen($strValues)-2);

$strSQL.=$strFields.") values ".$strValues.")";

LogInfo($strSQL);

set_error_handler("add_error_handler");

db_exec($strSQL,$conn);

set_error_handler("error_handler");

// move files

if(!$error_happened)

{

foreach ($files_move as $file)

{

move_uploaded_file($file[0],$file[1]);

if(strtoupper(substr(PHP_OS,0,3))!="WIN")

@chmod($file[1],0777);

}

foreach($files_save as $file)

{

if(file_exists($file["filename"]))

@unlink($file["filename"]);

$th = fopen($file["filename"],"w");

fwrite($th,$file["file"]);

fclose($th);

}

if ( $inlineedit==ADD_INLINE )

{

$status="ADDED";

$message=""."Datensatz hinzugefügt"."";

$IsSaved = true;

}

else

$message="<div class=message><<< "."Datensatz hinzugefügt"." >>></div>";

if($usermessage!="")

$message = $usermessage;

if($inlineedit==ADD_INLINE || $inlineedit==ADD_ONTHEFLY || function_exists("AfterAdd"))

{
$failed_inline_add = false;

if(array_key_exists("SVNR",$avalues))

$keys["SVNR"]=$avalues["SVNR"];

else

$failed_inline_add = true;

}
// after edit event

if(function_exists("AfterAdd"))

{

foreach($keys as $idx=>$val)

$avalues[$idx]=$val;

AfterAdd($avalues,$keys,$inlineedit);

}

}

}

else

{

$message = $usermessage;

$status="DECLINED";

$readavalues=true;

}

}
$defvalues=array();
// copy record

if(array_key_exists("copyid1",$_REQUEST) || array_key_exists("editid1",$_REQUEST))

{

$copykeys=array();

if(array_key_exists("copyid1",$_REQUEST))

{

$copykeys["SVNR"]=postvalue("copyid1");

}

else

{

$copykeys["SVNR"]=postvalue("editid1");

}

$strWhere=KeyWhere($copykeys);

$strSQL = gSQLWhere($strWhere);
LogInfo($strSQL);

$rs=db_query($strSQL,$conn);

$defvalues=db_fetch_array($rs);

// clear key fields

$defvalues["SVNR"]="";

//call CopyOnLoad event

if(function_exists("CopyOnLoad"))

CopyOnLoad($defvalues,$strWhere);

}

else

{

$defvalues["NAME"]="auswählen";

}
// set default values for the foreign keys

if(@$_SESSION[$strTableName."_mastertable"]=="personaldaten")

{

$defvalues["SVNR"]=@$_SESSION[$strTableName."_masterkey1"];

}
if($inlineedit==ADDONTHEFLY || true)

{

}

if($readavalues)

{

$defvalues["SVNR"]=@$avalues["SVNR"];

$defvalues["NAME"]=@$avalues["NAME"];

$defvalues["TITER"]=@$avalues["TITER"];

$defvalues["ANMERKUNGEN"]=@$avalues["ANMERKUNGEN"];

$defvalues["GRUPPE"]=@$avalues["GRUPPE"];

}
/*

foreach($defvalues as $key=>$value)

$smarty->assign("value
".GoodFieldName($key),$value);

*/
$linkdata="";

$includes="";

$arr_includes=array();

$bodyonload="";
if ( $inlineedit!=ADD_INLINE )

{

// include files
// validation stuff

$onsubmit="";

$needvalidate=false;
if($needvalidate)

{

if($inlineedit==ADD_ONTHEFLY)

$onsubmit="return validate_fly(this);";

else

$onsubmit="return validate();";

// $bodyonload="onload=\"".$bodyonload."\"";

}
if($inlineedit!=ADD_ONTHEFLY)

{

$includes.="<script language=\"JavaScript\" src=\"include/jquery.js\"></script>\r\n";

$includes.="<script language=\"JavaScript\" src=\"include/onthefly.js\"></script>\r\n";

if ($useAJAX)

$includes.="<script language=\"JavaScript\" src=\"include/ajaxsuggest.js\"></script>\r\n";

$includes.="<script language=\"JavaScript\" src=\"include/jsfunctions.js\"></script>\r\n";

}

if($inlineedit!=ADD_ONTHEFLY)

{

$includes.="<script language=\"JavaScript\">\r\n";

}

$includes.="var locale_dateformat = ".$locale_info["LOCALE_IDATE"].";\r\n".

"var locale_datedelimiter = \"".$locale_info["LOCALE_SDATE"]."\";\r\n".

"var bLoading=false;\r\n".

"var TEXT_PLEASE_SELECT='".addslashes("Bitte auswählen")."';\r\n";

if ($useAJAX) {

$includes.="var SUGGEST_TABLE='impfdaten_searchsuggest.php';\r\n";

}

if($inlineedit!=ADD_ONTHEFLY)

{

$includes.="</script>\r\n";

if ($useAJAX)

$includes.="<div id=\"search_suggest\"></div>\r\n";

}
$xt->assign("SVNR_fieldblock",true);

$xt->assign("NAME_fieldblock",true);

$xt->assign("TITER_fieldblock",true);

$xt->assign("ANMERKUNGEN_fieldblock",true);

$xt->assign("GRUPPE_fieldblock",true);
$body=array();

$formname="editform";

if($inlineedit!=ADD_ONTHEFLY)

{

if($onsubmit)

$onsubmit="onsubmit=\"".$onsubmit."\"";

$body["begin"]=$includes.

"<form name=\"editform\" encType=\"multipart/form-data\" method=\"post\" action=\"impfdaten_add.php\" ".$onsubmit.">".

"<input type=hidden name=\"a\" value=\"added\">";

$xt->assign("backbutton_attrs","onclick=\"window.location.href='impfdaten_list.php?a=return'\"");

$xt->assign("back_button",true);

}

else

{

$formname="editform".$id;

$body["begin"]="<form name=\"editform".$id."\" encType=\"multipart/form-data\" method=\"post\" action=\"impfdaten_add.php\" ".$onsubmit." target=\"flyframe".$id."\">".

"<input type=hidden name=\"a\" value=\"added\">".

"<input type=hidden name=\"editType\" value=\"onthefly\">".

"<input type=hidden name=\"table\" value=\"".postvalue("table")."\">".

"<input type=hidden name=\"field\" value=\"".postvalue("field")."\">".

"<input type=hidden name=\"category\" value=\"".postvalue("category")."\">".

"<input type=hidden name=\"id\" value=\"".$id."\">";

$xt->assign("cancelbutton_attrs","onclick=\"RemoveFlyDiv('".$id."');\"");

// $xt->assign("cancelbutton_attrs","onclick=\"RemoveFlyDiv('".substr($id,3)."');\"");

$xt->assign("cancel_button",true);

}

$xt->assign("save_button",true);

$xt->assign("reset_button",true);

}
if($message)

{

$xt->assign("message_block",true);

$xt->assign("message",$message);

}

//$xt->assign("status",$status);
$readonlyfields=array();
// show readonly fields
$record_id= postvalue("recordID");
if ($useAJAX)

{

if($inlineedit==ADD_ONTHEFLY)

$record_id=$id;
if ( $inlineedit==ADD_INLINE )

{

$linkdata=str_replace(array("&","<",">"),array("&amp;","&lt;","&gt;"),$linkdata);
}

else

{

$linkdata.="SetToFirstControl('".$formname."');";

if($inlineedit==ADD_SIMPLE)

{

$linkdata = "<script type=\"text/javascript\">\r\n".

"$(document).ready(function(){ \r\n".

$linkdata.

"});</script>";

}

else

{

$linkdata=$includes."\r\n".$linkdata;

$includes="var s;";

foreach($arr_includes as $file)

{

$includes.="s = document.createElement('script');s.src = '".$file."';\r\n".

"document.getElementsByTagName('HEAD')[0].appendChild(s);\r\n";

}

$linkdata=$includes."\r\n".$linkdata;
if(!@$_POST["a"]=="added")

{

$linkdata = str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$linkdata);

echo $linkdata;

echo "\n";

}

else if(@$_POST["a"]=="added" && ($error_happened || $status=="DECLINED"))

{

echo "<textarea id=\"data\">decli";

echo htmlspecialchars($linkdata);

echo "</textarea>";

}
}

}

}

else

{

}
if($inlineedit!=ADD_ONTHEFLY)

{

$body["end"]="</form>".$linkdata.

"<script>".$bodyonload."</script>";
$xt->assign("body",$body);

$xt->assign("flybody",true);

}

else

{

$xt->assign("flybody",$body);

$xt->assign("body",true);

}
if(@$_POST["a"]=="added" && $inlineedit==ADD_ONTHEFLY && !$error_happened && $status!="DECLINED")

{

$LookupSQL="";

if($LookupSQL)

$LookupSQL.=" from ".AddTableWrappers($strOriginalTableName);
$data=0;

if(count($keys) && $LookupSQL)

{

$where=KeyWhere($keys);

$LookupSQL.=" where ".$where;

$rs=db_query($LookupSQL,$conn);

$data=db_fetch_numarray($rs);

}

if(!$data)

{

$data=array(@$avalues[$linkfield],@$avalues[$dispfield]);

}

echo "<textarea id=\"data\">";

echo "added";

print_inline_array($data);

echo "</textarea>";

exit();

}
/////////////////////////////////////////////////////////////

// prepare Edit Controls

/////////////////////////////////////////////////////////////

$control_SVNR=array();

$control_SVNR["func"]="xt_buildeditcontrol";

$control_SVNR["params"] = array();

$control_SVNR["params"]["field"]="SVNR";

$control_SVNR["params"]["value"]=@$defvalues["SVNR"];

$control_SVNR["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_SVNR["params"]["mode"]="inline_add";

else

$control_SVNR["params"]["mode"]="add";

$xt->assignbyref("SVNR_editcontrol",$control_SVNR);

$control_NAME=array();

$control_NAME["func"]="xt_buildeditcontrol";

$control_NAME["params"] = array();

$control_NAME["params"]["field"]="NAME";

$control_NAME["params"]["value"]=@$defvalues["NAME"];

$control_NAME["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_NAME["params"]["mode"]="inline_add";

else

$control_NAME["params"]["mode"]="add";

$xt->assignbyref("NAME_editcontrol",$control_NAME);

$control_TITER=array();

$control_TITER["func"]="xt_buildeditcontrol";

$control_TITER["params"] = array();

$control_TITER["params"]["field"]="TITER";

$control_TITER["params"]["value"]=@$defvalues["TITER"];

$control_TITER["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_TITER["params"]["mode"]="inline_add";

else

$control_TITER["params"]["mode"]="add";

$xt->assignbyref("TITER_editcontrol",$control_TITER);

$control_ANMERKUNGEN=array();

$control_ANMERKUNGEN["func"]="xt_buildeditcontrol";

$control_ANMERKUNGEN["params"] = array();

$control_ANMERKUNGEN["params"]["field"]="ANMERKUNGEN";

$control_ANMERKUNGEN["params"]["value"]=@$defvalues["ANMERKUNGEN"];

$control_ANMERKUNGEN["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_ANMERKUNGEN["params"]["mode"]="inline_add";

else

$control_ANMERKUNGEN["params"]["mode"]="add";

$xt->assignbyref("ANMERKUNGEN_editcontrol",$control_ANMERKUNGEN);

$control_GRUPPE=array();

$control_GRUPPE["func"]="xt_buildeditcontrol";

$control_GRUPPE["params"] = array();

$control_GRUPPE["params"]["field"]="GRUPPE";

$control_GRUPPE["params"]["value"]=@$defvalues["GRUPPE"];

$control_GRUPPE["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_GRUPPE["params"]["mode"]="inline_add";

else

$control_GRUPPE["params"]["mode"]="add";

$xt->assignbyref("GRUPPE_editcontrol",$control_GRUPPE);
$xt->assign("style_block",true);
if(function_exists("BeforeShowAdd"))

BeforeShowAdd($xt,$templatefile);
if($inlineedit==ADD_ONTHEFLY)

{

$xt->load_template($templatefile);

$xt->display_loaded("style_block");

$xt->display_loaded("flybody");

}

else

$xt->display($templatefile);
function add_error_handler($errno, $errstr, $errfile, $errline)

{

global $readavalues, $message, $status, $inlineedit, $error_happened;

if ( $inlineedit!=ADD_SIMPLE )

$message=""."Eintrag NICHT hinzugefügt".". ".$errstr;

else

$message="<div class=message><<< "."Eintrag NICHT hinzugefügt"." >>>

".$errstr."</div>";

$readavalues=true;

$error_happened=true;

}

?>

[/codebox]

J
Jane 6/24/2009

Hi,
I'm not sure that I understand you.

Please clarify what and where do you want to do.

T
taroma7273 author 6/25/2009

Hi jane!
So I try to do better. I have a form and based on certain value of the form be actively the conditions wiederun an SQL update trigger and a date in a column in a database to register (follow-date). This all works with the script that I made habe.Ich wants but this function in the form of PHPrunner einbauen. I do not know why it is not processed, I think I will add it to the wrong place. Here I would just need help.

J
Jane 6/25/2009

Hi,
I recommend you to use Before record added or After record added events on the Events tab to update record.

T
taroma7273 author 6/26/2009

hi jane
many thanks for the support, in this direction have already been employed to try it again go through perhaps what I miss.

here are the tentative request to me if you are purely an example might like what can see.
best regards <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42188&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
TAROMA7273

J
Jane 6/26/2009

Hi,
I recommend you to check Advanced topics --> Events section in the PHPRunner Help:

http://www.xlinesoft.com/phprunner/docs/

T
taroma7273 author 7/28/2009

Hi Jane !!

am now back from vacation and could now go on, unfortunately not quite done with the desired but it is already now the times have done as you suggested, however, he writes to me now 2 rows into the table once the data as entered by the user and Once the extra data to calculate the volgetermins war as I in a row? ß please help me have a link with two screensohts given so you siest what I have done. I Hofe du wars even in holiday and now have energy for so annoying beginner like me
pictures

J
Jane 7/29/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.