![]() |
Help with php form
Hi,
I am extremely new to PHP. I have a form which is used to add/update data a mysql database. One of the fields is called "Approved' and I use a yes/no radio button to update the field. Is there a way to only allow certain team members see and or uddate the Approved field? I capture the username from the browser cookie. Here is the code I use for the form: <html> <head> <title>My Page</title> </head> <body> <align = center><h2>SureIt Entry/Update Form</h2></align> <?php // set database server access variables: $host = ""; $user = ""; $pass = ""; $db = ""; $tag=$_POST['tag']; $developer=$_POST['developer']; $application=$_POST['application']; $username=$_COOKIE["InfoMgrWT"]; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM revo.sureit where tag = '".$tag."' and developer ='".$developer."' and application = '".$application."'"; //print $query; //$query= "SELECT * from sureit"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $row = mysql_fetch_row($result); if($row[0]) { echo "<form name='ProdMove_1' action='sureit_update.php' method='POST'>"; echo "<div align='left'>"; } else { echo "<form name='ProdMove_1' action='sureit_insert.php' method='POST'>"; echo "<div align='left'>"; } echo "Tag<br>"; echo "<input type='text' name='tag' value='".$tag."'><BR><br>"; echo "Developer<br>"; echo "<input type='text' name='developer' value='".$developer."'><BR><br>"; echo "Application<br>"; echo "<input type='text' name='application' value='".$application."'><BR><br>"; echo "Description of Code change<br>"; echo '<textarea cols=60 rows=15 wrap="soft" name="descofchange">'.$row[3].'</textarea><BR><br>'; echo "Details<br>"; echo '<textarea cols=60 rows=15 wrap= "soft" name="details">'.$row[14].'</textarea><BR><br>'; echo "Description of Database Change<br>"; echo '<textarea cols=60 rows=15 wrap="hard" name="descofdbchange">'.$row[4].'</textarea><BR><br>'; echo "Front End Changes<br>"; echo '<textarea cols=60 rows=15 wrap="soft" name="frontendchanges">'.$row[9].'</textarea><BR><br>'; echo "Move Instructions<br>"; echo '<textarea cols=60 rows=15 wrap="soft" name="moveinst">'.$row[11].'</textarea><BR><br>'; echo "Post Move Validation<br>"; echo '<textarea cols=60 rows=15 wrap = "soft" name="postmovevalidate">'.$row[12].'</textarea><BR><br>'; echo "Move Validated<br>"; if ($row[15] == 'Y') { echo "<input type='radio' name='movevalidated' value='Y' checked >Y<br>"; echo "<input type='radio' name='movevalidated' value='N' >N<br>"; } else { echo "<input type='radio' name='movevalidated' value='Y' >Y<br>"; echo "<input type='radio' name='movevalidated' value='N' checked >N<br><br><br>"; } '<br><br>'; echo "Approved<br>"; if ($row[6] == 'Y') { echo "<input type='radio' name='approved' value='Y' checked >Y<br>"; echo "<input type='radio' name='approved' value='N' >N<br>"; } else { echo "<input type='radio' name='approved' value='Y' >Y<br>"; echo "<input type='radio' name='approved' value='N' checked >N<br><br>"; } echo "Cancelled<br>"; if ($row[13] == 'Y') { echo "<input type='radio' name='cancelled' value='Y' checked >Y<br>"; echo "<input type='radio' name='cancelled' value='N' >N<br>"; } else { echo "<input type='radio' name='cancelled' value='Y' >Y<br>"; echo "<input type='radio' name='cancelled' value='N' checked >N<br>"; } ?> <br> <input type = "submit" value = "Submit"> <br><br> <a href="http://revolab0.uswin.ad.vzwcorp.com/sureit_query.html">Back</a> </form> </body> </html> Thanks kevin |
I would query for the user security level and only show that radio if it is in a certain level or higher.
|
I agree with tony here, the best way is to check for their security level. You would need to have a users table in the sql with a column representing their security level. You would need to assign a default, such as "0" for that column, then that value increases by one each time on specific users when there is higher access to grant.
Lets say you have a usersystem that uses an sql table called "users". Using their userid, you query their info in the database, then establish whether or not to show them the specific content or not, based on their security level For this example, I'm using "$user['userid']" There may already be a variable like this to identify your users if you are integrating your script into an existing php system. Otherwise, you will need to develop a register/login system that handles sessions. Follow the comments below, introduced by "//" for more information and feel free to reply with any questions you have. PHP Code:
|
Thanks for the idea.. I'll give it a try and see what happens.
|
Quote:
|
| All times are GMT. The time now is 08:59 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0