PHP - Acl (access Control List)
In my project. I wanted an option that was going to give me more control over what my users can and could not do. I fount a ACL Sample and well the guy that made this must have been drunk. Any way I been working with it and putting it together so that it will work. The problem is that when I view the users current permissions it doesn't seem to display then right. Blow is the code i have in a switch that I use to manage each users permissions. The $_GET['uid'] gets the users id from the URL in the admin section.
Code: (php) [Select] case "manage": //$userACL = new ACL($_GET['uid']); $userACL = new ACL($_GET['uid']); echo '<h2>Managing '.$userACL->getUsername($_GET['uid']).'</h2>'; echo '... Some form to edit user info ...'; echo '<h5>Roles for user: (<a href="users.php?action=roles&uid='.$_GET['uid'].'">Manage Roles</a>)</h5>'; echo '<ul>'; $roles = $userACL->getUserRoles($_GET['uid']); foreach ($roles as $k => $v) { echo "<li>" . $userACL->getRoleNameFromID($v) . "</li>"; } echo '</ul>'; echo '<h6>Permissions for user: (<a href="users.php?action=perms&uid='.$_GET['uid'].'">Manage Permissions</a>)</h6>'; echo '<ul>'; //$uparms = $userACL->getAllPerms($_GET['uid']); //$uPerms = $userACL->getUserPerms($_GET['uid']); //$aPerms = $userACL->getAllPerms('full'); $aPerms = $userACL->perms; //foreach ($perms as $k => $v) foreach($aPerms as $k => $v) { //echo 'fdfdsfsd :'. $v['value']; //if ($v['value'] == false) { continue; } if($v['value']) { // if (!$v['value']) { continue; } echo "<li>" . $v['Name'] . ' : Allowed </li>'; //if ($v['inheritted']) { echo " (inheritted)"; } } else { echo "<li>" . $v['Name'] . ' : Deny </li>'; } echo "</li>"; } echo '</ul>'; break; If any one needs any extra info. Please let me know. Similar TutorialsHi everyone, am developing an application that has two views 1 for administrator and 1 for staff. Administrator can perform all application tasks and Staff can ONLY perform certain task. I have implemented sessions quite alright and are working. Now the problem is that when I login as Staff and then I change the URL to point to an administrator's page the application is allowing that, How can I prevent that from happening. Staff MUST NOT see administrators pages. Here is my login code, logout code and code am using to protect webpages below. Here is my login code <?php //start the session session_start(); $username=$_POST['username']; $password=$_POST['password']; $encrypted=md5($password); // set connection to database $hostname="localhost"; // Host name $mysql_server_username="root"; // Mysql username $server_password=""; // Mysql password $db_name="db_inventory"; // Database name $table = "tbl_users"; // Table name // Connect to server and select database. mysql_connect("$hostname", "$mysql_server_username", "$server_password")or die("cannot connect to database server"); mysql_select_db("$db_name") or die ("Couldn't select the database."); $admin=("select * from $table where username='$username' AND password='$encrypted' AND type = 'admin'"); $staff=("select * from $table where username='$username' AND password='$encrypted' AND type = 'staff'"); //check that at least one row was returned $adminresult=mysql_query($admin); $admincount = mysql_num_rows($adminresult); $staffresult=mysql_query($staff); $staffcount = mysql_num_rows($staffresult); if($admincount> 0){ $_SESSION['valid_user'] = $username ; header( "Location: main_menu.php" ); } else if($staffcount> 0){ $_SESSION['valid_user'] = $username ; header( "Location: staff/main_menu.php" ); } else { ?> <!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=utf-8" /> <title>title> | Login</title> </head> <body bgcolor="#FFFFFF" background-repeat:no-repeat; background="images/images1.jpg"> <div align="center"> <table width="800" height="501" border="0" cellpadding="1" cellspacing="1"> <tr> <td height="100"> </td> </tr> <tr> <td height="350"> <div align="center"> <form method="post" action="login_process.php"> <h4 align="center"><font color="red">Incorrect Username / Password ! Please Try Again</font></h4> <img name="" src=images/padlock_closed.gif width="34" height="32" alt="" /><br /><br /> <table width="314" border="0" cellspacing="1" cellpadding="1"> <tr> <td>Username:</td> <td><label> <input type="text" name="username" /> </label></td> </tr> <tr> <td>Password:</td> <td><label> <input type="password" name="password" /> </label></td> </tr> <tr> <td colspan="2"> <p> <input type="submit" name ="submit" value="Login" /> <input type="reset" value="Reset" /> </p> </td> </tr> </table> </form> </div> </td> </tr> <tr> <td height="100"> </td> </tr> </table> </div> </body> </html> <?php } ?> Here is my logout code <?php //start the session session_start(); //check to make sure the session variable is registered if(isset($_SESSION['valid_user'])){ //session variable is registered, the user is ready to logout session_unset(); session_destroy(); //the session variable isn't registered, the user shouldn't even be on this page header( "Location: index.php" ); } else { //check to see if the session variable is not registered if(!isset($_SESSION['valid_user'])){ //redirect to login page header( "Location: index.php" ); } } ?> Here is code I am using to protect pages <?php //start the session session_start(); //check to make sure the session variable is registered if(!isset($_SESSION['valid_user'])){ //redirect to login page header( "Location: index.php" ); } ?> <!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> | Main Menu</title> <link rel="stylesheet" type="text/css" href="css.css" /> </head> <body> <div id="tabsF"> <ul> <!-- CSS Tabs --> <li id="current"><a href="main_menu.php"><span>MAIN MENU</span></a></li> <li><a href="stockmaster.php"><span>STOCK MASTER</span></a></li> <li><a href="controlpanel.php"><span>CONTROL PANEL</span></a></li> <li><a href="logout.php"><span>LOGOUT</span></a></li> </ul> </div> </body> </html> Thank you. Below is the screenshots and script for user page level access i have used it for one of my old projects. Code is working as it was intended. But it needs to be improvised. Users table
pages table , which has all the pages and links
Access level table. which has user id from users table and page id from pages table (for which user has access)
Once the user is created, admin gives access to the user on page basis, the permissions.php page looks like this The modules
Menus inside the modules
Pages in each menu
Here is my code for permission.php <div id="demo2-html"> <ul id="demo2" class="mnav"> <li><a href="#">Sales</a> <ul> <li><a href="#">Lead</a> <ul> <table class="table table-bordered table-striped table-hover"> <?php $s1 = mysqli_query($con, "SELECT pages.page_id as pid, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id as pgid, access_level.user_id FROM pages LEFT JOIN access_level ON (pages.page_id=access_level.page_id AND access_level.user_id=".$user." ) WHERE pages.code='led'") or die(mysqli_error($con)); while($s2 = mysqli_fetch_array($s1)) { ?> <tr><li><td><?php echo $s2['page']; ?> </td><td><input type="checkbox" name="sn[]" value="<?php echo $s2['pid']; ?>" <?php if($s2['pgid'] === $s2['pid']) echo 'checked="checked"';?> /> <input type="hidden" value="<?php echo $s2['pid']; ?>" name="page_id[<?php echo $s2['pgid']; ?>]"> </td></li></tr> <?php } ?> </table> </ul> </li> <li><a href="#">Customer</a> <ul> <table class="table table-bordered table-striped table-hover"> <?php $s1 = mysqli_query($con, "SELECT pages.page_id as pid, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id as pgid, access_level.user_id FROM pages LEFT JOIN access_level ON (pages.page_id=access_level.page_id AND access_level.user_id=".$user." ) WHERE pages.code='cst'") or die(mysqli_error($con)); while($s2 = mysqli_fetch_array($s1)) { ?> <tr><li><td><?php echo $s2['page']; ?> </td><td><input type="checkbox" name="sn[]" value="<?php echo $s2['pid']; ?>" <?php if($s2['pgid'] === $s2['pid']) echo 'checked="checked"';?> /> <input type="hidden" value="<?php echo $s2['pid']; ?>" name="page_id[<?php echo $s2['pgid']; ?>]"> </td></li></tr> <?php } ?> </table> </ul> </li> //code goes for all the other modules </ul> </li> </ul> </div> <input type="hidden" name="user" value="<?php echo $user; ?>" /> <div class="row" align="center"> <input type="submit" name="submit" class="btn btn-success" value="Save" /> </form> // form Submission if(isset($_POST['submit'])) { $user = $_POST['user']; $sql = "DELETE FROM access_level WHERE user_id = ".$user.""; $query = mysqli_query($con, $sql) or die (mysqli_error($con)); foreach($_POST['sn'] as $sn) { $sql = "insert into access_level (page_id, user_id) values (".$sn.", ".$user.")"; $query = mysqli_query($con, $sql) or die (mysqli_error($con)); } if($query) { header("location:users.php?access=1"); } }
So against each user i am storing all the page ids here. When i edit any of the users, it deletes all the records and again insers new records. Which i feel is not a proper way to do. And in codewise also, i am redirecting the user to no_access.php (as below) page if the user do not have access. <?php ob_start(); include("connect.php"); include("admin_auth.php"); $q1 = basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']); $q2 = $_SERVER['REQUEST_URI']; $var1 = "/".$q1; $qa_path=explode('/', $q2); $right_path = $qa_path[2].$var1; $parsedUrl = parse_url($q2); $curdir = dirname($_SERVER['REQUEST_URI'])."/"; $m4 = "select p.page_id, p.code, p.page, p.href, al.aid, al.page_id, al.user_id FROM pages p INNER JOIN access_level al ON p.page_id=al.page_id WHERE al.user_id=".$_SESSION['user_id'].""; $m5 = mysqli_query($con, $m4) or die (mysqli_error($con)); while($nk1 = mysqli_fetch_array($m5)) { $href1[] = ($nk1['href']); } if(in_array($right_path, $href1)) { echo "<script type='text/javascript'> document.location = ".BASE_URL."/".$right_path."</script>"; } else { echo "<script type='text/javascript'> document.location = '../no_access.php' </script>"; exit(); } ?> I need help in improve and better/effective (structural) way to do this both in database and php script. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=333523.0 Hi, In my mysql database i have a text input option, in the registration form and edit my details form i have a multiple select dropdown list, which user selects options to populate the text input box, which ultimately populates the text field in the mysql database. All works perfectly. The dropdownlist consists of 3 parts <optgroups> first is current selection (what is the usesr current selection)works fine, The second <optgroup> is existing words, what words we(the site) have given as options, and the third <optgroup> is the words that others have used. This is where im having a small problem. Because its a text field when i call the data from the database, it calls the entire text box as a single option in my select list.. I want to break the words in the text field (at the comma) and have them listed each one as an option in the select list. Example what i need: Words in text box:(my input allows the "comma") word1, word2, word3, word4, word5, word6, How i want them called/displayed: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> here's my code: $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $original_functionsexperience =doSelectSql($query,1); $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $functionsexperiencelist=doSelectSql($query); $funcexpList ="<select multiple=\"multiple\" onchange=\"setFunctionsexperience(this.options)\">"; foreach ($functionsexperiencelist as $functionsexperienceal) { $selected=""; if ($functionsexperienceals->allwords == $original_functionsexperience) $selected=' selected="selected"'; $allwords=$functionsexperienceal->allwords; $funcexpList .= "<optgroup label=\"Current selection\"> <option value=\"".$allwords."\" ".$selected." >".$allwords."</option> </optgroup> <optgroup label=\"Existing Words\"> <option value=\"existing1,\">existing1</option> <option value=\"existing2,\">existing2</option> <option value=\"existing3,\">existing3</option> <option value=\"existing4,\">existing4</option> <option value=\"existing5,\">existing5</option> <option value=\"existing6,\">existing6</option> </optgroup> <optgroup label=\"Others added\"> //heres problem <option value=\"".$allwordsgeneral."\">".$allwordsgeneral."</option> </optgroup>"; } $funcexpList.="</select>"; $output['FUNCEXPLIST']=$funcexpList; The result im getting for optgroup others added: word1, word2, word3, word4, word5, how can i get it like this: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> Hi , I have one question .. Can I split showing of content of dynamic list in 2 parts , when I echo list in code .. Code: [Select] <?php // Run a select query to get my letest 8 items // Connect to the MySQL database include "../connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 8"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<table width="100%" border="2" cellspacing="2" cellpadding="2"> <tr> <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="2" /></a></td> <td width="83%" valign="top">' . $product_name . '<br /> $' . $price . '<br /> <a href="product.php?id=' . $id . '">View Product Details</a></td> </tr> </table>'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Code: [Select] <p><?php echo $dynamicList; ?><br /> </p> It works ok, and putting my files, everything works, but when I put 8 pictures with price and other details, it just show one image with details and another image below with details, and the third image below and so on .. Can I split dynamic list to show 4 images with details on the left side and 4 on the right side? Thank you in advance for help , if is possible Hi, I use the following code to create a select menu from an array of options stored in LISTS.php: include 'LISTS.php'; print('<select id="from" name="from">'); foreach ($langList as $lang) {printf('<option %s>%s</option>', ($from1 == $lang ? 'selected="selected"' : ''), $lang); } echo '</select>'; where LISTS.php includes the following: $langList = array(' ','English', 'French', 'German', 'Dutch', 'Spanish'); This works great, but now I want to do something similar with a checkbox list, where each checkbox has an associated 'onchange' javascript function and I'm getting pretty stuck. My checkbox list is of the following form: Code: [Select] <html> <ul style="height: 95px; overflow: auto; width: 200px; border: 1px solid #480091; list-style-type: none; margin: 0; padding: 0;"> <li id="li1b"><label for="chk1b"><input name="chk1b" id="chk1b" type="checkbox" onchange="function1('chk1b','li1b')">Option1</label></li> <li id="li2b"><label for="chk2b"><input name="chk2b" id="chk2b" type="checkbox" onchange="function1('chk2b','li2b')">Option2</label></li> //etc. </ul> </html> What I want to do is have 'Option1', 'Option2', etc. stored in an array in LISTS.php and have a PHP script that populates the checkbox list accordingly, in a similar manner to my select menu above. I can't work out how to get the ID of the next <li> and the next <input> in the list to go up by one each time, e.g. 'li1b' then 'li2b', 'li3b', etc. Could someone pls help me out? Thanks! Is there a way to take data that is listed like a,b,c,d,e and turn that into an unordered list? Basically, I'm going to have a list of schools that will be listed with comma separators. I'll print that data out in two places, one will be printed as it's in the database. The other I would like to echo as an unordered list. All, I have a script I wrote that works off a local machine directory, scans it for .html files and uploads those to the server. This works fine in test on my machine with WAMP installed and running localhost, but the activities are for reading/posting the files into my WordPress website and when I move the script to the host, the directory listings are now always the directory on the host machine and I have not figured out how to transfer the directory control back to the local machine. I captured the local directory setting into a 'tools' table I installed into the host MySQL DB. I have searched online for a good example of how to do this, both in the PHP libraries and the JavaScript libraries and have not found a good solution yet. I'm sure there is an example out there, but sure I just do not have the right keywords to find it, so would appreciate a link from anyone who has knowledge on where such a resource might be. Thanks! OMR Hi, I have a question. is that code below made a problem in google search, mean if I put this codes in header did google find my homepage? header( 'Cache-Control: no-store, no-cache, must-revalidate' ); header( 'Cache-Control: post-check=0, pre-check=0', false ); header( 'Pragma: no-cache' ); header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); Thnx. T I have a number of Forms which I want to control the input, for example prevent people from using numbers or ensure that people use specific characters. For example "Your password must contain a capital letter and at least one number". Does anyone know what code I should use to do this. I am running Apache with the PHP module installed on Debian Linux. My goal is to launch a binary in a background process and then feed it commands via fifo. The binary I need to launch has a config file which lives in the home directory of the apache user (in my case the user name apache is started with is www-data). www-data's home dir was the web root so I changed it to /home/www-data. I also change the shell from /bin/sh to /bin/bash for www-data. Neither of these changes are present when I load a php file from a browser. This script: Code: [Select] <?php echo "User: " . exec('whoami') . "<br>"; echo "Shell: " . exec('ps -p $$ | grep sh') . "<br>"; ?> Outputs this: Code: [Select] User: www-data Shell: 9179 ? 00:00:00 sh Also if I execute the binary it does seem to read the config file which is in the www-data users directory. I have set the home dir and the web root to be owned by www-data and it's read and writeable. How do I get php to execute the binary so it has access to the users home directory and uses the bash shell? Are there any other ways to launch and control a binary on a unix system via php? Hi guys! First of all I'd like to thank you for reading my question. I think it's a basic one indeed! I've started to learn php and wanted to code a small game in html + php. The principle is basic: I generate two random numbers between 1 and 10, $a and $b. I keep its sum in $result=$a+$b I echo them to the screen and ask the user to input their sum in an html form input field with a submit button. When I receive the value from the html form I want to compare if the user input is equal to the sum of the two numbers presented. What happens is that when I hit the submit button the browser reads all the code again and generates two new numbers $a and $b and I cannot compare if what the user inputted is true or not because the browser reads all the file. My question is how can I control the flow of the program to avoid it. Any tips for a newby like me? i have homework about this but i don't know how to make it work, after a few hours it stuck with every login will go to same place i must create 4 id : 1.owner : can access all page , edit all id 2.chasier : report any item out, only access item out page (item.php) 3.warehouse : add item from purchasing department, add new item, get notification from chasier, tell purchasing department to buy item 4.purchasing department : get notification from warehouse, sent report to warehouse after add stock or add new item login.php Code: [Select] <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="cek_login.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="username" type="text" id="username"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> cek_login.php Code: [Select] <?php $host="localhost"; $username="root"; $password=""; $db_name="shop_system"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $username=$_POST['username']; $password=$_POST['password']; $usertype=$_GET['usertype']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password' "; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("username"); session_register("password"); header("location:sukses.php"); } else { echo "Wrong Username or Password"; } ?> sukses.php Code: [Select] <? session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <body> Login Successful </body> </html> How hard would something like this be? I have a database with all my users. I need an empty list and when a user clicks a button "Add me to the list" they are added to the first position in the list Slots 1. Tom 2. 3. 4. 5. Later, Jerry wants to be added to the list. So this happens Slots 1. Jerry 2. Tom 3. 4. 5. More people join the list 1. Bob 2. John 3. Jerry 4. Tom 5. Tom gets upset clicks the same button to join the list again, and he's bumped back up to first place. Slots 1. Tom 2. Bob 3. John 4. Jerry 5. Is this possible? And is so, how would I go about getting started on such a thing? I've been using PHP for about a year and a half. I'm trying to control the load order of the browser. The default load order is from top to bottom. Well I have a table that is made in html with more code bellow the table. My php data that I put inside the html table is Code: [Select] <?php include("table/table.php"); ?> that grabs the data that will go into my html table. Well the problem I'm having is that the rest of the table with stuff under the table won't load till the php is done being processed. This makes my site look weird for 4 seconds and is the reason why I want to load the php content last. Is there a way to do this with php or javascript? Hi all . I have a button now when i click the button an mypages is valid can i make that button in the page invisible in postback with php?? I know you can in C# by saying button1.Visible = false; Thanks for input... I currently have two robots wirelessly controlled with a web-server and streaming webcam. Now I would like to create some form of queuing system so that only one user can have control over one robot at a time for a limited amount of time (~5 mins) before being kicked off. I would prefer that any waiting users would be presented with an estimate of their time remaining upon visiting the webpage. However, I am not sure how to go about doing this. Does anybody have any suggestions? Hello,
I am making a UCP to go along side a game server. The game server adds a mysql row when a account is created and places the password under Whirlpool encryption.
I am looking for someone who can help me make a basic login page that needs to enter a user name and password, with the password then encrypting to Whirlpool or whatever needs to be done for the login to be a success.
I am a total new guy to HTML / PHP scripting and looking to do this as a learning project.
Control problem based on two forms Hello everyone, I have a problem with the control of my two forms principle it is good for the first form, but if I wanted to control my 2nd form, blocking ca Here's the script: Code: [Select] <html> <head> <script type="text/javascript" > function formValidation1(oEvent) { oEvent = oEvent || window.event; var txtField = oEvent.target || oEvent.srcElement; var txt_nom_pereck1=true; var msg=" "; if(document.getElementById("txt_nom_pere").value.length < 3 ){ txt_nom_pereck1=false; msg = msg + "Your name should be minimun 3 char length";} if(document.getElementById("txt_prenom_pere").value.length < 3 ){ txt_nom_pereck1=false; msg = msg + "Your name should be minimun 3 char length";} if(txt_nom_pereck1){document.getElementById("submit_etape4").style.display='block'; } else{document.getElementById("submit_etape4").style.display='none'; } } window.onload = function () { var submit_etape4 = document.getElementById("submit_etape4"); var txt_nom_pere = document.getElementById("txt_nom_pere"); var txt_prenom_pere = document.getElementById("txt_prenom_pere"); var txt_courriel_pere = document.getElementById("txt_courriel_pere"); var txt_courriel_pere_conf = document.getElementById("txt_courriel_pere_conf"); var txt_nom_pereck1=false; document.getElementById("submit_etape4").style.display='none'; txt_nom_pere.onkeyup = formValidation1; txt_prenom_pere.onkeyup = formValidation1; } //************Partie 2 : ******///////////////////////////// /* function formValidation2(oEvent) { oEvent = oEvent || window.event; var txtField = oEvent.target || oEvent.srcElement; var txt_nom_pereck2=true; var msg=" "; if(document.getElementById("txt_courriel_pere").value.length < 3 ){ txt_nom_pereck2=false; msg = msg + "Your name should be minimun 3 char length";} if(document.getElementById("txt_courriel_pere_conf").value.length < 3 ){ txt_nom_pereck2=false; msg = msg + "Your name should be minimun 3 char length";} if(txt_nom_pereck2){document.getElementById("submit_etape5").style.display='block'; } else{document.getElementById("submit_etape5").style.display='none'; } } window.onload = function () { var submit_etape5 = document.getElementById("submit_etape5"); var txt_courriel_pere = document.getElementById("txt_courriel_pere"); var txt_courriel_pere_conf = document.getElementById("txt_courriel_pere_conf"); var txt_nom_pereck2=false; document.getElementById("submit_etape5").style.display='none'; txt_nom_pere.onkeyup = formValidation2; txt_prenom_pere.onkeyup = formValidation2; } Je voulais activer cette partie pour comtrole le Form 2 Le probleme existe au niveau des nom des fonctions I wanted this part to enable the Comtrol Form 2 The problem exists at the level of function names */ </script> </head> <body > <form method=" post" action="form-success.php"> <table> <tr> <td>First Name</td> <td><input type="text" id="txt_nom_pere" name="FirstName"></td> </tr> <tr> <td>First Name</td> <td><input type="text" id="txt_prenom_pere" name="FirstName"></td> </tr> </table> <input type="button" id="submit_etape4" value="Sign Up!!" style="display:none;" /> </form> <form method=" post" action="form-success.php"> <table> <tr> <td>First Name</td> <td><input type="text" id="txt_courriel_pere" name="FirstName"></td> </tr> <tr> <td>First Name</td> <td><input type="text" id="txt_courriel_pere_conf" name="FirstName"></td> </tr> </table> <input type="button" id="submit_etape5" value="Sign Up!!" style="display:none;" /> </form> </body> </html> Hi Everybody i am working on admin panel but right now i encounter a problem i can't edit i also can't delete news but insert is working maybe somebody can help me find mistake and fix it up . You can visit web and see what is what Admin Panel http://faksx.sytes.net/blogs/?page=cp Admin Panels news management http://faksx.sytes.net/blogs/?page=news_cp user andis |pw andis (don't try hack it won't work) Here is code i . if ($_POST['submit']) { $id = (int)$_POST['id']; $news_title = mysql_real_escape_string($_POST['news_title']); $news_category = mysql_real_escape_string($_POST['news_category']); $news_short_text = mysql_real_escape_string($_POST['news_short_text']); $news_text = mysql_real_escape_string($_POST['news_text']); $news_title = htmlentities($_POST['news_title']); $news_category = htmlentities($_POST['news_category']); $news_short_text = htmlentities($_POST['news_short_text']); $news_text = htmlentities($_POST['news_text']); if (!empty($id)) { $sql = ("UPDATE news SET news_title = '$news_title', news_category = '$news_category', news_short_text = '$news_short_text', news_text = '$news_text' WHERE id = '$id' "); } else { $sql = "INSERT INTO news (news_title,news_category,news_short_text,news_text,news_author,news_date) VALUES ('".$news_title."','".$news_category."','".$news_short_text."','".$news_text."','".$_SESSION[u_nick]."','".$last_time_seen."')"; mysql_query($sql) or die (mysql_error()); } } if($_GET['edit'] == 1) { $id = (int)$_GET['id']; $sql = ("DELETE FROM news WHERE id = '$id'"); mysql_query($sql) or die (mysql_error()); } if ($_GET['edit'] == 1) { $id = (int)$_GET['id']; $sql = ("SELECT * FROM news WHERE id = '$id'"); $date = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($date); $edit_title = $row['news_title']; $edit_group = $row['news_category']; $edit_short_text = $row['news_short_text']; $edit_text = $row['news_text']; $edit_id = (int)$row['id']; } mysqlutf8(); $sql = ("SELECT * FROM news"); $date = mysql_query($sql) or die (mysql_error()); echo '<select>'; while($row = mysql_fetch_array($date)) { echo "<option value='$row[id]'>".$row[news_title].'</option>' ; } #" <a href='/blogs/?page=comment&id=".$row['id']."'>Comment</a> " #"<a href='/blogs/?page=news_cp&edit=id=".$row['id']."'>" echo '</select>'."<a href='/blogs/?page=news_cp&edit&id=".$row['id']."'><input type='button' name='edit' id='button2' value='Edit' /></a> <a href='/blogs/?page=news_cp&delete&id=".$row['id']."'><input type='button' name='delete' id='button3' value='Delete' /></a>"; echo "<form id='form1' name='submit' method='post'> <p>Virsrakts <label for='textfield'></label> </p> <p> <input type='text' name='news_title' value='$news_title'> </p> <p>Ziņu Gruppa</p> <p> <label for='select'></label> <select name='news_category' value='$edit_group'> <option>News</option> <option>Bugs</option> </select> </p> <p>Teksts</p> <p> <label for='textfield2'></label> <textarea name='news_short_text' cols='50' rows='10' id='textfield2' value='$edit_short_text_text'></textarea> </p> <p>Pilns Teksts</p> <p> <label for='textfield3'></label> <textarea name='news_text' cols='70' rows='15' id='textfield3' value='$news_text'></textarea> </p> <p> <input type='submit' name='submit' id='button' value='Pievienot' /> <input type='reset' name='reset' id='button4' value='Reset' /> </p> </form>"; } |