Re: [PHP-DB] search of data base - again
On Fri, Mar 30, 2012 at 1:10 AM, Ethan Rosenberg wrote: > Sending again, since no response on 1st try. > > Ethan > == > Dear List > > I am trying to insert data into a table, with no success. > > I have two tables: > > mysql> describe Visit3; > ++--+--+-+-++ > | Field | Type | Null | Key | Default | Extra | > ++--+--+-+-++ > | Indx | int(4) | NO | PRI | NULL | auto_increment | > | Site | varchar(6) | YES | | NULL | | > | MedRec | int(6) | YES | | NULL | | > | Notes | text | YES | | NULL | | > | Weight | int(4) | YES | | NULL | | > | BMI | decimal(3,1) | YES | | NULL | | > | Date | date | YES | | NULL | | > ++--+--+-+-++ > > ++-+--+-+-+---+ > | Field | Type | Null | Key | Default | Extra | > ++-+--+-+-+---+ > | Site | varchar(6) | NO | PRI | | | > | MedRec | int(6) | NO | PRI | NULL | | > | Fname | varchar(15) | YES | | NULL | | > | Lname | varchar(30) | YES | | NULL | | > | Phone | varchar(30) | YES | | NULL | | > | Height | int(4) | YES | | NULL | | > | Sex | char(7) | YES | | NULL | | > | Hx | text | YES | | NULL | | > ++-+--+-+-+---+ > > I calculate some values: > > default_timezone_set('America/New_York'); > $Date = date('M d Y'); > $sql1 = "select MedRec, Height from Intake3 where (MedRec = > '$_POST[MedRec]')"; > $result = mysqli_query($cxn, $sql1); > $row = mysqli_fetch_array($result); > $MedRec = $row[0]; > $Height = $row[1]; > $Weight = $_POST['Weight']; > $Notes = $_POST['Notes']; > $sql4 = "select MedRec, Weight from Visit3 where (MedRec = > $_POST[MedRec])"; > $result4 = mysqli_query($cxn, $sql4); > $row4 = mysqli_fetch_array($result4); > $MedRec = $_POST['MedRec']; > $BMI = ($Weight*703)/($Height*$Height); > $BMI = round($BMI,1); > $fptr1 = fopen("/home/ethan/PHP/HRecnumSite", "r+"); > fscanf($fptr1,"%d %s",$Num, $Site); > echo "$Site, $MedRec, $Notes, $Weight $BMI, $Date "; > $sql2 = "INSERT INTO Visit3(Indx, Site, MedRec, Notes, Weight, BMI, > Date) VALUES(null, '$Site', '$MedRec', '$Notes', $Weight, $BMI, '$Date'"; > $result2 = mysqli_query($cxn, $sql2); > > They display properly. > > $sql3 = "select max(Indx) from Visit3"; > $result3 = mysqli_query($cxn, $sql3); > var_dump($result3); > echo "result3 "; > print_r($result3); > $row = mysqli_fetch_array($result3); > $Indx = $row[0]; > > echo "\n"; > > echo " $Indx \n"; > echo " $Site \n"; > echo " $MedRec \n"; > echo " $Notes \n"; > echo " $Weight \n"; > echo " $BMI \n"; > echo " $Date \n"; > > echo "\n"; > echo ""; > > The date value is not inserted properly into the table: > > mysql> select * from Visit3; > | 2416 | AA | 10001 | uih s45t | 125 | 19.0 | -00-00 | > | 2417 | AA | 1 | bnkjlolk | 174 | 28.1 | -00-00 | > > Advice and help, please. > > Thanks. > > Ethan Rosenberg > I think MySQL wants the date in -M-D format, did you try changing $Date = date('M d Y'); to $Date = date('Y-m-d'); - Matijn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] search of data base - again
Sending again, since no response on 1st try. Ethan == Dear List I am trying to insert data into a table, with no success. I have two tables: mysql> describe Visit3; ++--+--+-+-++ | Field | Type | Null | Key | Default | Extra | ++--+--+-+-++ | Indx | int(4) | NO | PRI | NULL| auto_increment | | Site | varchar(6) | YES | | NULL|| | MedRec | int(6) | YES | | NULL|| | Notes | text | YES | | NULL|| | Weight | int(4) | YES | | NULL|| | BMI| decimal(3,1) | YES | | NULL|| | Date | date | YES | | NULL|| ++--+--+-+-++ ++-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | ++-+--+-+-+---+ | Site | varchar(6) | NO | PRI | | | | MedRec | int(6) | NO | PRI | NULL| | | Fname | varchar(15) | YES | | NULL| | | Lname | varchar(30) | YES | | NULL| | | Phone | varchar(30) | YES | | NULL| | | Height | int(4) | YES | | NULL| | | Sex| char(7) | YES | | NULL| | | Hx | text| YES | | NULL| | ++-+--+-+-+---+ I calculate some values: default_timezone_set('America/New_York'); $Date = date('M d Y'); $sql1 = "select MedRec, Height from Intake3 where (MedRec = '$_POST[MedRec]')"; $result = mysqli_query($cxn, $sql1); $row = mysqli_fetch_array($result); $MedRec = $row[0]; $Height = $row[1]; $Weight = $_POST['Weight']; $Notes = $_POST['Notes']; $sql4 = "select MedRec, Weight from Visit3 where (MedRec = $_POST[MedRec])"; $result4 = mysqli_query($cxn, $sql4); $row4 = mysqli_fetch_array($result4); $MedRec = $_POST['MedRec']; $BMI = ($Weight*703)/($Height*$Height); $BMI = round($BMI,1); $fptr1 = fopen("/home/ethan/PHP/HRecnumSite", "r+"); fscanf($fptr1,"%d %s",$Num, $Site); echo "$Site, $MedRec, $Notes, $Weight $BMI, $Date "; $sql2 = "INSERT INTO Visit3(Indx, Site, MedRec, Notes, Weight, BMI, Date) VALUES(null, '$Site', '$MedRec', '$Notes', $Weight, $BMI, '$Date'"; $result2 = mysqli_query($cxn, $sql2); They display properly. $sql3 = "select max(Indx) from Visit3"; $result3 = mysqli_query($cxn, $sql3); var_dump($result3); echo "result3 "; print_r($result3); $row = mysqli_fetch_array($result3); $Indx = $row[0]; echo "\n"; echo " $Indx \n"; echo " $Site \n"; echo " $MedRec \n"; echo " $Notes \n"; echo " $Weight \n"; echo " $BMI \n"; echo " $Date \n"; echo "\n"; echo ""; The date value is not inserted properly into the table: mysql> select * from Visit3; | 2416 | AA | 10001 | uih s45t |125 | 19.0 | -00-00 | | 2417 | AA | 1 | bnkjlolk |174 | 28.1 | -00-00 | Advice and help, please. Thanks. Ethan Rosenberg -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: [PHP-WIN] Flow of PHP testClass
Yes, I believe your understanding is correct... This is my understanding as well. In line 1 below, you are creating a new object and using the class constructor to initialize $a and $b. In line 2 below, you are creating a new object, with $a and $b's default values. In line 3 below, $a and $b are printed with the values passed through the class constructor in line 1. In line 4 below, $a and $b are printed with default values since nothing was passed through the class constructor. 1 . $inst1 = new TestClass(3,50); 2 . $inst2 = new TestClass(); 3. $inst1-‐>printAB(); 4. $inst2-‐>printAB(); -Original Message- From: Rikin Parekh [mailto:riki...@gmail.com] Sent: Thursday, March 29, 2012 10:57 AM To: PHP DB; php-wind...@lists.php.net; phpexperts-subscr...@yahoogroups.com Subject: [PHP-WIN] Flow of PHP testClass Hi Guys, Given below is a PHP script. Can someone help me with the output of the code. According to my understanding the output should be 3, 50, 20, 10. Can someone elaborate on the same and provide me an explanation on the flow? Thanks a lot in advance. a= $a; } if(!is_null($b)) { $this-‐>b=$b; } } function printAB() { echo $this-‐>a.” “.$this-‐>b.”\n”; } } $inst1 = new TestClass(3,50); $inst2 = new TestClass(); $inst1-‐>printAB(); $inst2-‐>printAB(); ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Flow of PHP testClass
Hi Guys, Given below is a PHP script. Can someone help me with the output of the code. According to my understanding the output should be 3, 50, 20, 10. Can someone elaborate on the same and provide me an explanation on the flow? Thanks a lot in advance. a= $a; } if(!is_null($b)) { $this-‐>b=$b; } } function printAB() { echo $this-‐>a.” “.$this-‐>b.”\n”; } } $inst1 = new TestClass(3,50); $inst2 = new TestClass(); $inst1-‐>printAB(); $inst2-‐>printAB(); ?>
Re: [PHP-DB] Session and Access Privilages.
Yup, With some help from Jey earlier today, I was able to figure it out.. I only realized it later, how easy it was since all the auth types were being set already, the same piece of code at the beginning of every page should have been good ! Thanks, Vinay On Thu, Mar 29, 2012 at 7:28 PM, Govinda wrote: > > Hey, > > > > I am working on the application, thought its not OOP currently, I plan to > > take it further in a year or so. > > Right now, I have 4 access levels which define what the users can do on > the > > application. > > Based on the access levels defined, a session varialble is set called > > $_SESSION['authtype'], and this defines what are the links shown to the > > user. > > so basically the session authtype, defines what links are shown to the > > users, now i am thinking that if a user comes to know of a link whihc he > > does not have > > access to, he / she can put that in the url and try to gain access, what > i > > feel is there should be some check on each of the page for the access and > > if the acess > > criteria is not met, then the user should be sent back to him home page > > view. > > > > Any ideas on what the best way is to implement something like this? Any > > help is appreciated. > > > > Thanks, > > Vinay > > > Hi Vinay > > If you are already checking your $_SESSION['authtype'] var, to know > whether or not to display certain links.. then you can just add the same > kind of checking at the top of any code that should be reserved for a > certain level of user. If someone without proper access has hacked the URL > then just redirect to your login page, or whatever you want to do to the > intruders. > > HTH > -Govinda
Re: [PHP-DB] Session and Access Privilages.
> Hey, > > I am working on the application, thought its not OOP currently, I plan to > take it further in a year or so. > Right now, I have 4 access levels which define what the users can do on the > application. > Based on the access levels defined, a session varialble is set called > $_SESSION['authtype'], and this defines what are the links shown to the > user. > so basically the session authtype, defines what links are shown to the > users, now i am thinking that if a user comes to know of a link whihc he > does not have > access to, he / she can put that in the url and try to gain access, what i > feel is there should be some check on each of the page for the access and > if the acess > criteria is not met, then the user should be sent back to him home page > view. > > Any ideas on what the best way is to implement something like this? Any > help is appreciated. > > Thanks, > Vinay Hi Vinay If you are already checking your $_SESSION['authtype'] var, to know whether or not to display certain links.. then you can just add the same kind of checking at the top of any code that should be reserved for a certain level of user. If someone without proper access has hacked the URL then just redirect to your login page, or whatever you want to do to the intruders. HTH -Govinda -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Session and Access Privilages.
Hi- Since you are checking the authtype variable in the environmental variable for each page which is requested, There cannot be any chance for a intruder to get access to the page. But then, for an enhanced security, do maintain a table in db with relation between authtype and access to page and privilege. Checking the same in the page before displaying it to the user might help you in solving the issue. Hope this helps. - Trinath S On Thu, Mar 29, 2012 at 1:00 PM, Vinay Kannan wrote: > Hey, > > I am working on the application, thought its not OOP currently, I plan to > take it further in a year or so. > Right now, I have 4 access levels which define what the users can do on the > application. > Based on the access levels defined, a session varialble is set called > $_SESSION['authtype'], and this defines what are the links shown to the > user. > so basically the session authtype, defines what links are shown to the > users, now i am thinking that if a user comes to know of a link whihc he > does not have > access to, he / she can put that in the url and try to gain access, what i > feel is there should be some check on each of the page for the access and > if the acess > criteria is not met, then the user should be sent back to him home page > view. > > Any ideas on what the best way is to implement something like this? Any > help is appreciated. > > Thanks, > Vinay >
[PHP-DB] Session and Access Privilages.
Hey, I am working on the application, thought its not OOP currently, I plan to take it further in a year or so. Right now, I have 4 access levels which define what the users can do on the application. Based on the access levels defined, a session varialble is set called $_SESSION['authtype'], and this defines what are the links shown to the user. so basically the session authtype, defines what links are shown to the users, now i am thinking that if a user comes to know of a link whihc he does not have access to, he / she can put that in the url and try to gain access, what i feel is there should be some check on each of the page for the access and if the acess criteria is not met, then the user should be sent back to him home page view. Any ideas on what the best way is to implement something like this? Any help is appreciated. Thanks, Vinay