m@m Posted October 6, 2011 Share Posted October 6, 2011 I wanted to understand this coding.Please help me. :'( <?php require_once('Connections/doctorsblog.php'); ?> <?php // Load the common classes require_once('includes/common/KT_common.php'); // Load the tNG classes require_once('includes/tng/tNG.inc.php'); // Make a transaction dispatcher instance $tNGs = new tNG_dispatcher(""); // Make unified connection variable $conn_doctorsblog = new KT_connection($doctorsblog, $database_doctorsblog); if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $mes=""; $maxRows_Recordset1 = 4; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_doctorsblog, $doctorsblog); $query_Recordset1 = "SELECT * FROM blog WHERE status = 1 ORDER BY blogid DESC"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $doctorsblog) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; if(isset($_POST['kt_login1'])) { $newencrypass=md5($_POST['password']); $newencrypass=trim($newencrypass); $user=trim($_POST['admin_username']); mysql_select_db($database_doctorsblog, $doctorsblog); $query_Recordset3 = "SELECT * FROM doctors WHERE username = '{$user}' and encryptedpassword='{$newencrypass}'"; $Recordset3 = mysql_query($query_Recordset3, $doctorsblog) or die(mysql_error()); $row_Recordset3 = mysql_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysql_num_rows($Recordset3); if($totalRows_Recordset3>0) { /*//$normal_pass = $_POST['password']; $encripted_pass = $row_Recordset2['encryptedpassword']; if(md5($normal_pass) == $encripted_pass) $encrppassword=$row_Recordset2['encryptedpassword']; else $encrppassword=md5($normal_pass); */ // Make a login transaction instance $loginTransaction = new tNG_login($conn_doctorsblog); $tNGs->addTransaction($loginTransaction); // Register triggers $loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "kt_login1"); $loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}"); // Add columns $loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "admin_username"); $loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "password"); // End of login transaction instance // Execute all the registered transactions $tNGs->executeTransactions(); // Get the transaction recordset $rscustom = $tNGs->getRecordset("custom"); $row_rscustom = mysql_fetch_assoc($rscustom); $totalRows_rscustom = mysql_num_rows($rscustom); } if($totalRows_Recordset3==0){ $mes="Invalid username or password"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Blogs Home</title> <script type="text/javascript" src="images/jquery_002.js" charset="utf-8"></script> <script type="text/javascript" src="images/jquery.js" charset="utf-8"></script> <!--<script type="text/javascript"> jQuery(function() { jQuery('body').showMessage({'thisMessage':['First login then manage blogs.'],className:'success',displayNavigation:false,useEsc:false,delayTime:2000, autoClose:true}); }); </script> --> <style type="text/css"> <!-- body { background-color: #c6c6c6; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-image: url(); } .success { font-family: Arial, Helvetica, clean, sans-serif; font-size: 15px; font-weight: bold; background-color: #93BBD9; padding:0px; width:200px; margin:0px; color: black; text-align:center; border-radius:0 0 18px 18px; -moz-border-radius:0 0 18px 18px; } .success ul { padding:0px; margin:0px; } body a{color:#CC3366; text-decoration:none; font-family:Verdana, Arial, Helvetica, sans-serif; } --> </style> <script language="JavaScript" src="images/validate.js"></script> <script language="JavaScript" src="images/validate_002.js"></script> <link href="images/directory.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style1 {color: #b61850} --> </style> <script type="text/javascript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } //--> </script> <style type="text/css"> <!-- .style2 {color: #333333} .style3 {color: #FFFFFF} .style1 {color: #b61850} --> </style> </head> <body><div class="success" id="showMessage" style="position: fixed; z-index: 1001; left: 0px; width: 100%; margin: 0px; opacity: 0.9; top: 0px; display: none;"><div style="width: 90%; margin: 1em auto; padding: 0.5em;"><ul style="font-size: large; font-weight: bold; margin-left: 0px; padding-left: 0px;"><li style="list-style: none outside none;">First login then manage blogs.</li></ul></div></div> <table width="1044" align="center" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td background="images/whitebg.jpg"><table width="1000" align="center" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" align="left"><table width="1000" align="center" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td width="1000" height="143" align="center"><?php include("header.php");?></td> </tr> </tbody></table></td> </tr> <tr> <td valign="top" align="left"> <table width="1000" align="center" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td class="pinkverdana10" height="40" valign="middle" align="left"> Home</td> </tr> <tr> <td class="pinkverdana10" height="10" valign="middle" align="left"></td> </tr> <tr> <td valign="top" align="left"><table class="verdana10" width="983" align="center" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" width="79%"><table width="98%" align="left" bgcolor="#93BBD9" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td width="12"><img src="images/yellow1.jpg" height="16" width="12"></td> <td height="16" width="100%" background="images/yellowtop.htm"></td> <td height="16" width="2%" align="right"><img src="images/yellow2.jpg" height="16" width="12"></td> </tr> <tr> <td align="left" background="images/yellowleft.htm"> </td> <td height="30" valign="top" align="left"><span class="welcome">BLOGS</span></td> <td background="images/yellowrghitr.htm"> </td> </tr> <tr> <td align="left" background="images/yellowleft.htm"> </td> <td class="verdana_gary12" valign="top" align="left"> </td> <td background="images/yellowrghitr.htm"> </td> </tr> <tr> <td align="left" background="images/yellowleft.htm"> </td> <td valign="top" bgcolor="#93BBD9"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" align="left"><table width="100%" bgcolor="#93BBD9" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" width="678" align="left"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" align="left"><table class="arielblack" width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" align="left"> </td> </tr> <tr> <td valign="top" align="left"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" width="20" align="left"> </td> <td valign="top" align="left"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td valign="top" align="left"><?php do { ?> <?php mysql_select_db($database_doctorsblog, $doctorsblog); $query_Recordset2 = "SELECT * FROM doctors WHERE docid = ".$row_Recordset1['fromassociated'].""; $Recordset2 = mysql_query($query_Recordset2, $doctorsblog) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td valign="top" align="left"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td class="welcome" valign="top" align="left"><a href="showdetail.php?id=<?php echo $row_Recordset1['blogid']; ?>" style="color:#154A75;"><?php echo $row_Recordset1['btitle']; ?></a></td> <td valign="top" width="10" align="left"> </td> <td valign="top" width="170" align="right"><span class="verdana_yellow12">Posted by <?php echo $row_Recordset2['fname']; ?> <?php echo $row_Recordset2['lname']; ?><br> <?php echo date('M d, Y', strtotime($row_Recordset1['postdate'])); ?></span></td> </tr> </tbody></table></td> </tr> <!--<tr> <td align="left" valign="top" class="bottomline"> </td> </tr> --> <tr> <td valign="top" align="left"> </td> </tr> <tr> <td valign="top" align="left"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td valign="top" align="left"> <?php $length=strlen($row_Recordset1['description']); if($length>200) { $actual=substr_replace($row_Recordset1['description'], '...', 200, $length); echo $actual; } else{ echo $row_Recordset1['description']; } ?> <a href="showdetail.php?id=<?php echo $row_Recordset1['blogid']; ?>" style="color:#154A75; font-weight:bold;">Read More...</a></td> </tr> <tr> <td valign="top" align="left"> </td> </tr> <tr> <td class="tags" valign="top" align="left">Tags: <span style="color:#154A75; font-weight:bold;"><?php echo $row_Recordset1['tagscloud']; ?> </span></td> </tr> <tr> <td class="bottomline" valign="top" align="left"> </td> </tr> <tr> <td valign="top" align="left"> </td> </tr> <tr> <td valign="top" align="left"> </td> </tr> <tr> <td valign="top" align="left"> </td> </tr> </tbody> </table></td> </tr> </tbody> </table></td> </tr> </tbody> </table> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?></td> </tr> </tbody></table></td> <td valign="top" width="35" align="left"> </td> </tr> </tbody></table></td> </tr> <tr> <td valign="top" align="left"> </td> </tr> <tr> <td valign="top" align="center"><!--<table width="50%" border="0" cellspacing="1" cellpadding="0"> <tr class="whiteariel11"> <td width="29%" align="right"><span class="redarielblack"><a href="#" class="redarielblack">Result Page previous</a> :: </span></td> <td width="5%" align="center" valign="middle" bgcolor="#F60E95" class="whiteariel11"><a href="#" class="whiteariel11">1</a> </td> <td width="5%" align="center" valign="middle" bgcolor="#F60E95"><a href="#" class="whiteariel11">2</a></td> <td width="5%" align="center" valign="middle" bgcolor="#F60E95"><a href="#" class="whiteariel11">3</a></td> <td width="5%" align="center" valign="middle" bgcolor="#F60E95"><a href="#" class="whiteariel11">4</a></td> <td width="5%" align="center" valign="middle" bgcolor="#F60E95"><a href="#" class="whiteariel11">5</a></td> <td width="5%" align="center" valign="middle" bgcolor="#F60E95"><a href="#" class="whiteariel11">6</a></td> <td width="11%" align="left"><span class="redarielblack"> :: <a href="#" class="redarielblack">Next</a></span></td> </tr> </table> --></td> </tr> <tr> <td valign="top" align="left"></td> </tr> </tbody></table></td> </tr> </tbody></table></td> </tr> </tbody></table></td> </tr> </tbody></table></td> <td background="images/yellowrghitr.htm"> </td> </tr> <tr> <td align="left"><img src="images/yellow3.jpg" height="16" width="12"></td> <td background="images/yellowbootam.htm"></td> <td align="right"><img src="images/yellow4.jpg" height="16" width="12"></td> </tr> </tbody></table></td> <td valign="top" width="21%" align="right"><?php include("right.php");?></td> </tr> </tbody></table> <p> </p> <p> </p></td> </tr> <tr> <td> </td> </tr> <tr> <td height="1" bgcolor="#e8e8e8"></td> </tr> <tr> <td> </td> </tr> <tr> <td class="copyright" align="center"><?php include("footer.php");?></td> </tr> </tbody></table></td> </tr> <tr> <td valign="top" align="left"> </td> </tr> </tbody></table></td> </tr> <tr> <td height="20" background="images/whitebgfooter.jpg"> </td> </tr> </tbody></table> </td></tr></tbody></table></body></html> <?php mysql_free_result($Recordset1); mysql_free_result($Recordset2); mysql_free_result($Recordset3); ?> Anyone Please explain this coding for me.... Thanks Lot. Quote Link to comment https://forums.phpfreaks.com/topic/248523-help-me-to-understand-this-coding-part/ Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 6, 2011 Share Posted October 6, 2011 This a PHP area of the forum. Most of that code you pasted contains HTML and SQL. If you want someone to help explain whats going on with the PHP, strip everything from the document except the PHP. If the code is too long people probably won't reply. People have better things to do that read an encyclpedia for someone, but if the codes short then you will probably find people can explain breifly the function of the code. The PHP manual is pretty good for explaining what each function does (something like if() or echo()), so if you learn what the functions do and step back and look at them working together, you will probably figure out the purpose of the document. http://php.net/manual/en/index.php If you can't understand what the page does, then you've probably ripped the script off a tutorial site. That site should have a description of the function. Quote Link to comment https://forums.phpfreaks.com/topic/248523-help-me-to-understand-this-coding-part/#findComment-1276299 Share on other sites More sharing options...
m@m Posted October 6, 2011 Author Share Posted October 6, 2011 yes,you're correct.but here i paste all of these because experts can understand it very easily.... anyway can anyone pls explain this coding part .. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } Quote Link to comment https://forums.phpfreaks.com/topic/248523-help-me-to-understand-this-coding-part/#findComment-1276304 Share on other sites More sharing options...
Buddski Posted October 6, 2011 Share Posted October 6, 2011 It is hard to explain a complex section of code without anybody knowing what your skill level is, if you are VERY new to PHP then some of the items in that code will be hard to understand. The best way to learn about each section is to look at the Manual, that is what it is there for. Ill even get you started The main part is switch() The assignment of $theValue inside the switch is being done by the use of a ternary operator Quote Link to comment https://forums.phpfreaks.com/topic/248523-help-me-to-understand-this-coding-part/#findComment-1276306 Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 6, 2011 Share Posted October 6, 2011 That document to me looks like it is made for pulling text out of a SQL database based in given options and displaying the relevant text accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/248523-help-me-to-understand-this-coding-part/#findComment-1276308 Share on other sites More sharing options...
m@m Posted October 6, 2011 Author Share Posted October 6, 2011 It is hard to explain a complex section of code without anybody knowing what your skill level is, if you are VERY new to PHP then some of the items in that code will be hard to understand. The best way to learn about each section is to look at the Manual, that is what it is there for. Ill even get you started The main part is switch() The assignment of $theValue inside the switch is being done by the use of a ternary operator I have some knowledge in PHP.Can anyone please explain What has happend in that coding part.. :'( Thanks Quote Link to comment https://forums.phpfreaks.com/topic/248523-help-me-to-understand-this-coding-part/#findComment-1276359 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.