Jump to content

gibbo1715

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gibbo1715's Achievements

Member

Member (2/5)

0

Reputation

  1. Many thanks, i just needed to re add the $row++; and that gave me exactly what I was after Thanks so much for helping with this, been trying to figure it out all day but new to PHP, certainly learning a lot though
  2. All I am not the best at PHP and have been trying to work out how to make a treeview from an array. I managed to get as afar as populating my array as i would like and I can get those values back but now im really stuck What id love to be able to do is use my area field as the parent and my title field as the child and have a counter on the parent with no of child nodes. If someone can help me out with that bit id be really greatful, as I ve already sorted my javascript etc this is my last problem and its driving me nuts Many Thanks for looking and i really do appreciate any help Gibbo <?php $row = 0; $myarray = array(); foreach ($view->result as $result) { $arg = $view->render_field('field_decision_type_value', $row); $arg2 = $view->render_field('title', $row); $myarray[$row]["area"]=$arg; $myarray[$row]["title"]=$arg2; $row++; } asort($myarray); $last = count($myarray) - 1; $rowcount=0; while ($rowcount <= $last) { print $myarray[$rowcount]["area"]; print $myarray[$rowcount]["title"].'|<br />'; $rowcount++; } ?>
  3. Hi all, Apologies if i ve put this in the wrong forum but heres my question(s) Im looking for what you consider to be the best php/mysql code generator to develop a crud application, I also need (Either through that or something seperate) to be able to manage security via individuals and group level access. so based on this access dictates what they can do with each part of the database. For example id like the admin to be able to delete but a user to only be able to delete a specific page or a group of users to be only able to delete a specific page or update it etc.... Hope that makes sense Can anyone offer any advice please on either Thanks Gibbo
  4. great, thanks for the reply, that answers my question and sort of is what i expected if i ve got it right i.e. store the primary key of the user in the session and then query the database for the rest when a new page is called to ensure security in maintained. Thats more in line with what im used to thanks again Gibbo
  5. thanks for the reply, so instead of calling the database each time I load a page and checking the access level of the user it is better to call that information once and store the information in a session and then check the session on each page ( If im reading your reply right), that makes sense Many Thanks Gibbo
  6. Hi All I am playing around with various ways of managing access to the pages on my site and one thought came to mind What is the best way to manage the security, shoudl i call the information from a database each time or use cookies, is there an agreed best way to do this, Im not used to php yet but somehow calling a database seems more secure (Until someone tells me different) im also after a really good free user/ usergroup management system i can learn from so if anyone can suggest anything it would be appreciated, im not after a full cms, just a security management system i can learn from Many Thanks gibbo
  7. HI All Im trying to get the excellent AGTC-membership script, it all works apart from the admin.php page and for the life of me i cant figure out why Its exactly as downloaded and running on xampp my sql, the database is working fine and can log in and out etc, its just this one page that gives me the arror Parse error: syntax error, unexpected $end in C:\web\xampp\htdocs\e\manageusers\admin.php on line 157 can anyone help me with whats causing my problem please as this is the last bit i need to get working and i ve been trying all day to figure it out myself unsuccessfully thanks Gibbo <?php // ************************************************************************************************* // Title: PHP AGTC-Membership system v1.1a // Developed by: Andy Greenhalgh // Email: andy@agtc.co.uk // Website: agtc.co.uk // Copyright: 2005(C)Andy Greenhalgh - (AGTC) - Updated 04.06.06 // Licence: GPL, You may distribute this software under the terms of this General Public License // ************************************************************************************************* // session_start(); include "level4_check.php"; $msg = "To edit a record click on the user name, to list by order click on titles.<br>YOU CANNOT EDIT ADMIN IN DEMO MODE."; if(isset($_POST['Amend'])) { $username = $_POST['username']; $userlevel = $_POST['userlevel']; $userid = $_POST['userid']; $result = mysql_query("Update login_table set user_name='$username', user_level='$userlevel' where userid=".$_POST['userid']); $msg = "Record is updated<br>To edit a record click on the user name"; $edit = ""; } if(isset($_POST['Submit'])) { $total = $_POST['total']; $td = 0; $i = 0; for($i = 1; $i <= $total; $i++) { if(isset($_POST["d$i"])) { mysql_query("DELETE FROM login_table WHERE userid=".$_POST["d$i"],$con); $td++; } } $msg = "$td record(s) deleted!<br>To edit a record click on the user name"; } if ($order == "") {$order = "userid";} $result = mysql_query("Select * from login_table ORDER BY '$order'",$con); $num = mysql_num_rows($result); $n = 0; ?> <html> <head> <title>Admin</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#E1DEFE"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <th class="header" scope="col"><div align="left" style="margin-left:10px;">AGTC - PHP Login management v1.1a - Administration - Developed by <strong>AGTC Websolutions @ </strong><a href="http://www.agtc.co.uk" target="_blank">http://www.agtc.co.uk</a></p></div></th> </tr> </table> <form name="form1" method="post" action=""> <p class="smallTextBlack"><?php echo $msg; ?><br>USER LEVELS:<BR>1 = (HIGH RESTRICTION - CAN ACCESS LEVEL 1 ONLY)<BR>2 = (MEDIUM RESTRICTION - CAN ACCESS BOTH LEVELS 2 & 1)<BR>3 = (LOW RESTRICTION - CAN ACCESS BOTH LEVELS 3, 2 & 1)<BR>4 = (ADMIN AND ALL LEVELS)</p> <table width="100%" border="0" cellpadding="1" cellspacing="1" bordercolor="#000000"> <tr bgcolor="#A39FF6" class="standardText"> <td width="5%" background="images/bar.gif"><div align="center" class="smallTextWhite">DELETE</div></td> <td width="5%" background="images/bar.gif"><div align="center"><a class="standardText" href="admin.php?order=userid">ID</a></div></td> <td width="20%" background="images/bar.gif"><div align="center"><a class="standardText" href="admin.php?order=user_name">USER NAME</a> </div></td> <td width="20%" background="images/bar.gif"><div align="center" class="smallTextWhite">PASSWORD </div></td> <td width="5%" background="images/bar.gif"><div align="center"><a class="standardText" href="admin.php?order=user_level">LEVEL</a></div></td> <td width="20%" background="images/bar.gif"><div align="center"><a class="standardText" href="admin.php?order=user_email">EMAIL</a></div></td> <td width="5%" background="images/bar.gif"><div align="center" class="smallTextWhite">USER IP </div></td> <td width="20%" background="images/bar.gif"><div align="center"><a class="standardText" href="admin.php?order=date">DATE REGISTERED</a> </div></td> </tr> <?php while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $n++; ?> <tr> <td width="5%"><div align="center"><?php if ($row['userid'] <> "185") { ?> <input type="checkbox" name="d<?php echo $n;?>" value="<?php echo $row['userid'];?>"><? } ?> </div></td> <td width="5%"><?php echo $row['userid'];?></td> <td width="20%"><?php if($row['userid'] > "1") { ?><a href="admin.php?edit=<?php echo $row['user_name']?>"><?php } echo $row['user_name'];?></a></td> <td width="20%"><?php echo $row['user_pass'];?></td> <td width="5%"><center><?php echo $row['user_level'];?></center></td> <td width="20%"><?php echo $row['user_email'];?></td> <td width="10%"><?php echo $row['user_ip'];?></td> <td width="20%"><center><?php echo $row['date'];?></center></td> </tr> <?php }?> </tr> <div align="center"></div> </table> <input type="submit" name="Submit" value="Delete"> <input name="total" type="hidden" id="total" value="<?php echo $n?>"> <p> </p></form> <!-- FORM FOR AMENDMENT --> <?php if ($edit) {$msg = "Edit record below"; if ($edit == "admin") {$msg = "You cannot edit Admin in this demo"; exit ();} $result = mysql_query("Select * from login_table WHERE user_name = '$edit'",$con); $row = mysql_fetch_array($result) ?> <form name="form2" method="post" action=""> <div class="smallTextBlack">Edit user :-</div> <table width="60%" border="0" cellpadding="1" cellspacing="1" bordercolor="#000000"> <tr bgcolor="#999999" class="smallTextWhite"> <td background="images/bar.gif"><div align="center" class="smallTextWhite">ID</div></td> <td background="images/bar.gif"><div align="center" class="smallTextWhite">USER NAME </div></td> <td width="20%" background="images/bar.gif"><div align="center" class="smallTextWhite">USER LEVEL </div></td> <td background="images/bar.gif"><div align="center" class="smallTextWhite">DATE REGISTERED </div></td> </tr> <tr> <td width="5%"><center><?php echo $row['userid'];?></center></td> <td width="15%"><input type="username" name="username" value="<?php echo $row['user_name'];?>"></a></td> <td width="15%">Change level: <select name="userlevel"> <option>1</option> <option>2</option> <option>3</option> <option>4</option></select> <span class="smallErrorText">CURRENTLY SET AT LEVEL: <?php echo $row['user_level'];?></span></td> <td width="10%"><div align="center"><?php echo $row['date'];?></div> </td> </tr> </table> <input type="hidden" name="userid" value="<?php echo $row['userid'];?>"> <input type="Submit" name="Amend" value="Update"></form> <?php }?> <p><a href="index.php">Back to index page</a></p> </body> </html>
  8. Thankyou for your replies, it is currently on a linux server but may end up on a microsoft one, Last modified is also fine for me so i d be interested if there is a way to order by either of those in a different way. Many Thanks for your help Gibbo
  9. Hi All Still pretty new to PHP so I hope this isnt too much of a daft question I need to loop through some files and return the result with the most recently created first, I think i ve found a way to list the items by date order but I cant figure out how to return just the file name, might also be that im returning the values with the oldest first actually, not checked yet, Can anyone assist please thanks gibbo <?php $path = './js/'; $list = listdir_by_date($path); foreach($list as $key => $value) { print "$key: $value<br>"; } function listdir_by_date($path){ $dir = opendir($path); $list = array(); while($file = readdir($dir)){ if ($file != '.' and $file != '..'){ // add the filename, to be sure not to // overwrite a array key $ctime = filectime($path . $file) . ',' . $file; $list[$ctime] = $file; } } closedir($dir); krsort($list); return $list; } ?>
  10. All This works for me although feels a bit messy Gibbo if ($this->form_validation->run('books_rules') ==FALSE) { if($this->input->post('mysubmit')){ if($this->input->post('id')){ $data['fid']['value'] = $this->input->post('id'); } } $this->load->view('books_input',$data); } else { if($this->input->post('mysubmit')){ if($this->input->post('id')){ $this->books_model->entry_update(); }else{ $this->books_model->entry_insert(); } } }
  11. Hi Folkes This is driving me nuts, probably because it is the last thing I need to figure out before i am able to have something working in php/ code igniter for the first time i have a list with an edit button that opens my edit page where i can edit items submit and all works fine. Then I tried to do form_validation, and i can get the validation error messages working fine, what i cant do is get the page to remember what record it is on when the validation fails and the url refreshes without the record number (Which i guess is my problem, i.e. http://localhost/index.php/books/input/6 becomes http://localhost/index.php/books/input if the form_validation fails If anyone can offer me some assistance i would be vbery greatfull My view is as follows <html> <head> <link rel="stylesheet" type="text/css" href="<?php echo "$base/$css"?>"> </head> <body> <div id="header"> <? $this->load->view('books_header'); ?> </div> <div id="menu"> <? $this->load->view('books_menu'); ?> </div> <table border="1"> <tr> <th colspan="2" ALIGN="center"><? echo heading($forminput,3) ?> <? if((int)$fid['value'] > 0){ echo 'Policy: ' .$fid['value']; } else { echo 'New Entry'; } ?></th> </tr> <? echo form_open('books/input'); ?> <? echo form_hidden('id',$fid['value'], set_value('id'));?> <tr> <th><? echo $title ?> </th> <th><? echo form_input($ftitle, set_value('title')).br();?> <?//echo set_value('$title'); ?> <!--Validation from my form_validation.php file in the config folder--> <?php echo form_error('title'); ?> </th> </tr> <tr> <th><? echo $author ?> </th> <th><? echo form_input($fauthor, set_value('author')).br(); ?> <!--Validation from my form_validation.php file in the config folder--> <?php echo form_error('author'); ?> </th> </tr> <tr> <th><? echo $publisher ?> </th> <!--Validation from my form_validation.php file in the config folder--> <th><? echo form_input($fpublisher, set_value('publisher')).br(); ?> <?php echo form_error('publisher'); ?> </th> </tr> <tr> <th><? echo $year ?> </th> <th><? echo form_dropdown('year',$years, set_value($fyear['value'])).br(); ?> </th> </tr> <tr> <th><? echo $available ?> </th> <th><? echo form_checkbox($favailable, set_value('available')).br(); ?> </th> </tr> <tr> <th><? echo $summary ?> </th> <th><? echo form_textarea($fsummary, set_value('summary')).br(); ?> </th> </tr> <tr> <th colspan="2" ALIGN="right"> <? if((int)$fid['value'] > 0){ echo form_submit('mysubmit','Update Record'); } else { echo form_submit('mysubmit','Add Record'); } ?> <? //echo form_submit('mysubmit','Submit!'); ?></th> </tr> </table> <? echo form_close(); ?> <div id="footer"> <? $this->load->view('books_footer'); ?> </div> </body> </html> And my controller for that view <?php class Books extends Controller{ function Books(){ parent::Controller(); $this->load->model('books/books_model'); } function main(){ $data = $this->global_model->general(); $data['query'] = $this->books_model->books_getall(); $this->load->view('books_main',$data); } function input($id = 0){ $data = $this->global_model->general(); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if((int)$id > 0){ $query = $this->books_model->get($id); $data['fid']['value'] = $query['id']; $data['ftitle']['value'] = $query['title']; $data['fauthor']['value'] = $query['author']; $data['fpublisher']['value'] = $query['publisher']; $data['fyear']['value'] = $query['year']; if($query['available']=='yes'){ $data['favailable']['checked'] = TRUE; }else{ $data['favailable']['checked'] = FALSE; } $data['fsummary']['value'] = $query['summary']; } if ($this->form_validation->run('books_rules') ==FALSE) { //Get the id somehow here //if ($this->uri->segment(3) === FALSE) $this->load->view('books_input',$data); } else { if($this->input->post('mysubmit')){ if($this->input->post('id')){ $this->books_model->entry_update(); }else{ $this->books_model->entry_insert(); } } $this->form_validation->id = $fid['value']; } } function del($id){ $data = $this->global_model->general(); if((int)$id > 0){ $this->books_model->delete($id); } $data['query'] = $this->books_model->books_getall(); $this->load->view('books_main',$data); } } Many thanks Let me know if i need to put more code here gibbo
  12. All I was introduced via this forum to a fantastic framework called codeigniter which im assuming a number of you are familiar with I have got everything i want working except for the validation aspect where i need a little help and i ll try and explain how i ve got things set up as best i can I have been playing using arrays to populate my form view data as follows //Set up the table components as I want them viewed here $data['ftitle'] = array('name'=>'title', 'size'=>30 ); $data['fauthor'] = array('name'=>'author', 'size'=>30 ); $data['fpublisher'] = array('name'=>'publisher', 'size'=>30 ); $data['favailable'] = array('name'=>'available', 'value'=>'yes', 'checked'=>TRUE ); $data['fsummary'] = array('name'=>'summary', 'rows'=>5, 'cols'=>60 ); //end books ******************************************* return $data; In in my view page i call this as follows <th><? echo $publisher ?> </th> <!--Validation from my form_validation.php file in the config folder--> <th><? echo form_input($fpublisher).br(); ?> <?php echo form_error('publisher'); ?> </th> and so on..... This all works fine and i can get the form validation working as well but i cant figure out how to not loose my data when the validation fails im aware of the set_value() function but not sure how i would use that as part of my form_input command? Can anyone assist or do i need to go a totally different route thanks gibbo P.S. hope that makes sense if not i ll try and explain a little better
  13. I am just progamming php as a hobby at the mo and dont really have anything i want to build yet, just enjoying learning the language but would like to make sure as I go I learn to do things right thanks Gibbo
  14. Thanks got it working although clearly not the right way to go Is codeigniter a good framework to use then, im assuming i just upload the libraries with my site and call them? I will do some reading now, just thought id ask the basic question first thanks again gibbo
  15. ok, the first part is i need a get instead of post (opps) but still doesnt work for me
×
×
  • 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.