falkencreative Posted October 4, 2011 Author Report Share Posted October 4, 2011 The point of the is_numeric() line is to ensure that someone isn't trying to mess with the website by inputting code into the URL. However, if the value you are expecting in the URL that you are using isn't numeric, then you will need to remove that if statement. Quote Link to comment Share on other sites More sharing options...
oninho Posted October 9, 2011 Report Share Posted October 9, 2011 I'm impressed with your code and it is real working...!!! Can you help me another code similar to these which will allow a logged in user to view and edit only his/her information from different tables?? Please help me..... Quote Link to comment Share on other sites More sharing options...
sakarora Posted October 10, 2011 Report Share Posted October 10, 2011 The point of the is_numeric() line is to ensure that someone isn't trying to mess with the website by inputting code into the URL. However, if the value you are expecting in the URL that you are using isn't numeric, then you will need to remove that if statement. Hi Ben, THANKS FOR YOUR REPLY... what and how much portion is to be removed?? plz be specific... i am newbie... when i remove if loop it gives me blank page when i click on edit.... or tell me what is to be written in place of is_numeric... if i want user to be enter characters only.. P.S i removed if (isset($_POST['submit'])) { // confirm that the 'id' value is a valid integer before getting the form data if (is_string($_POST['signum'])) { // get form data, making sure it is valid $signum =$_POST['signum']; $name = mysql_real_escape_string(htmlspecialchars($_POST['name'])); $emp_id = mysql_real_escape_string(htmlspecialchars($_POST['emp_id'])); // check that firstname/lastname fields are both filled in if ($name == '' || $emp_id == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; //error, display form renderForm($signum, $name, $emp_id, $error); } else { // save the data to the database mysql_query("UPDATE EMP SET name='$name', emp_id='$emp_id' WHERE signum='$signum'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: view.php"); } } else { // if the 'id' isn't valid, display an error echo 'Error!'; } } PLEASE EDIT THE SCRIPT FOR ME AND PASTE IT OVER HERE IF POSSIBLE... Quote Link to comment Share on other sites More sharing options...
kalfredsson Posted October 10, 2011 Report Share Posted October 10, 2011 Hi Ben and thanks for this awsome guide! I'm trying to create a dynamic table based on your example where the only real difference is that I want to have a different kind of PRIMARY KEY. In other words I want my site visitors to be able to see and edit the primary key which will be in text form (varchar). What kind of changes should I do in the code? Thanks again Albersson Quote Link to comment Share on other sites More sharing options...
sakarora Posted October 11, 2011 Report Share Posted October 11, 2011 The point of the is_numeric() line is to ensure that someone isn't trying to mess with the website by inputting code into the URL. However, if the value you are expecting in the URL that you are using isn't numeric, then you will need to remove that if statement. Thankyou Thankyou Thankyou... i am done with it.. thanks alot Ben... :* Quote Link to comment Share on other sites More sharing options...
jiroh Posted October 16, 2011 Report Share Posted October 16, 2011 uhm hey what is the database used here Access or SQL ? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted October 16, 2011 Author Report Share Posted October 16, 2011 uhm hey what is the database used here Access or SQL ? The system uses a MySQL database. Quote Link to comment Share on other sites More sharing options...
cool Posted November 15, 2011 Report Share Posted November 15, 2011 great info.thanks for this. i have some other questions? how to view only one row data? Example:- Add a VIEW link after EDIT and DELETE. when click on view show only that id values. (with code) thanks Quote Link to comment Share on other sites More sharing options...
falkencreative Posted November 15, 2011 Author Report Share Posted November 15, 2011 great info.thanks for this. i have some other questions? how to view only one row data? Example:- Add a VIEW link after EDIT and DELETE. when click on view show only that id values. (with code) thanks It would be nearly identical to the edit.php page, except that you wouldn't need to put the record's values in a form for editing purposes, and you won't need code to process the form and update the record. Quote Link to comment Share on other sites More sharing options...
cool Posted November 16, 2011 Report Share Posted November 16, 2011 thanks ben. now my view link also working. Quote Link to comment Share on other sites More sharing options...
rijz Posted December 5, 2011 Report Share Posted December 5, 2011 hi... Am a beginner in PHP. I have question, If the table(in the above post it is players) is to be selected from the database(for ex:technologies). Then i need a solution where user select from the different tables and that table is displayed. Please help.... Quote Link to comment Share on other sites More sharing options...
falkencreative Posted December 6, 2011 Author Report Share Posted December 6, 2011 hi... Am a beginner in PHP. I have question, If the table(in the above post it is players) is to be selected from the database(for ex:technologies). Then i need a solution where user select from the different tables and that table is displayed. Please help.... I think you'll need to explain what you need a bit more before I can help you. Quote Link to comment Share on other sites More sharing options...
lonkarprajakta29 Posted December 8, 2011 Report Share Posted December 8, 2011 hey awsm work....it really helped me a lot...but in this i m facing one problem in edit.php....In my form i have used drop down list. I am not able to retrieve the result of that drop down list while editing the form. When i redirected to edit.php the fields having drop down list show first option in drop down list instead of showing selecting option while adding data...plsss help me in this....should i post my code? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted December 8, 2011 Author Report Share Posted December 8, 2011 hey awsm work....it really helped me a lot...but in this i m facing one problem in edit.php....In my form i have used drop down list. I am not able to retrieve the result of that drop down list while editing the form. When i redirected to edit.php the fields having drop down list show first option in drop down list instead of showing selecting option while adding data...plsss help me in this....should i post my code? Yes. Create a new topic and post your question/the code you are working with. Quote Link to comment Share on other sites More sharing options...
lonkarprajakta29 Posted December 8, 2011 Report Share Posted December 8, 2011 Yes. Create a new topic and post your question/the code you are working with. i have crated nw topic as u said ben...but m nt getting proper respons..u pls take a luk at that topic...else just suggest me simple editing code for drop down list.its very urgent Quote Link to comment Share on other sites More sharing options...
sadakalo Posted December 8, 2011 Report Share Posted December 8, 2011 thanks for the information, i will practice myself Quote Link to comment Share on other sites More sharing options...
jgill916 Posted December 15, 2011 Report Share Posted December 15, 2011 Hi Ben, first of all great thanks to you for this script and it is going to help me a lot at work. I was actually setting it up with our own database and added all the row names and so on. Editing, adding, viewing results works just fine. But the only problem I dealing with is when I try to delete any existing record. I believe that whenever I change DELETE FROM content WHERE id_number=$id_number in delete.php file ($id_number is the row in my custom database so had to change it), it shows different error each time. Right now if I have it like that then I get an error saying You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 But then If I change mysql_query to DELETE FROM content WHERE id_number='$id_number' then it will not delete that file but will redirect me to listed location. Would you please help me figure out the problem? Here is the whole delete.php here if you need to go through it: <?php /* DELETE.PHP Deletes a specific entry from the 'content' table */ // connect to the database include('connect-db.php'); // check if the 'id' variable is set in URL, and check that it is valid if (isset($_GET['id_number']) && is_numeric($_GET['id_number'])) { // get id value $id = $_GET['id_number']; // delete the entry $result = mysql_query("DELETE FROM content WHERE id_number='$id_number'") or die(mysql_error()); // redirect back to the view page header("Location: view-paginated.php?page=4"); } else // if id isn't set, or isn't valid, redirect back to view page { header("Location: view-paginated.php?page=4"); } ?> Thank you in advance Mr. Falk. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted December 16, 2011 Author Report Share Posted December 16, 2011 This line itself should be fine, as far as I can tell: DELETE FROM content WHERE id_number='$id_number' Things to double check though: -- Do you have a "content" table in the database? -- Do you have an "id_field" column in that database? (and if so, is it spelled differently? "ID_field" for example) Quote Link to comment Share on other sites More sharing options...
roberi Posted December 22, 2011 Report Share Posted December 22, 2011 Thank you for making this script I have a question, what does the function renderForm do? Quote Link to comment Share on other sites More sharing options...
Coreinsanity Posted December 24, 2011 Report Share Posted December 24, 2011 Hi Ben, first of all great thanks to you for this script and it is going to help me a lot at work. I was actually setting it up with our own database and added all the row names and so on. Editing, adding, viewing results works just fine. But the only problem I dealing with is when I try to delete any existing record. I believe that whenever I change DELETE FROM content WHERE id_number=$id_number in delete.php file ($id_number is the row in my custom database so had to change it), it shows different error each time. Right now if I have it like that then I get an error saying But then If I change mysql_query to DELETE FROM content WHERE id_number='$id_number' then it will not delete that file but will redirect me to listed location. Would you please help me figure out the problem? Here is the whole delete.php here if you need to go through it: <?php /* DELETE.PHP Deletes a specific entry from the 'content' table */ // connect to the database include('connect-db.php'); // check if the 'id' variable is set in URL, and check that it is valid if (isset($_GET['id_number']) && is_numeric($_GET['id_number'])) { // get id value $id = $_GET['id_number']; // delete the entry $result = mysql_query("DELETE FROM content WHERE id_number='$id_number'") or die(mysql_error()); // redirect back to the view page header("Location: view-paginated.php?page=4"); } else // if id isn't set, or isn't valid, redirect back to view page { header("Location: view-paginated.php?page=4"); } ?> Thank you in advance Mr. Falk. I don't actually see $id_number defined in your code on that file. Are you sure you don't mean $id instead? Because I see: $id = $_GET['id']; Quote Link to comment Share on other sites More sharing options...
sibichan Posted January 16, 2012 Report Share Posted January 16, 2012 thanks sir. I started php few days ago. thanks for this simple php script. i will try to add more options like catagory,views. Quote Link to comment Share on other sites More sharing options...
Guest Danish Posted January 17, 2012 Report Share Posted January 17, 2012 Hello, Great work i am really impress with your work. This should help those wishing to learn some php. It is also a good start to the Admin side of small applications. Quote Link to comment Share on other sites More sharing options...
metabee Posted January 19, 2012 Report Share Posted January 19, 2012 Will you add new features? 1)Check/Uncheck all checkboxes based on one check box to delete multiple records and press the delete button (I mean only one button). 2)Check on the checkbox to select the record you want to update and press the update button (I mean only one button). Quote Link to comment Share on other sites More sharing options...
fdefreitas Posted February 7, 2012 Report Share Posted February 7, 2012 thank you very much for the code, the code has been helpful for me, although I am not a rookie with php and mysql, your example helped me a lot. however, I would like if possible to help me with something extra, I modified the instructions mysql and have adapted to an application with foreign keys in innodb table, Using innodb table, the update is not working, I've checked the code from the bottom up and top to bottom, the only thing that I changed are the mysql instructions, which operate under mysqlworbench. I know the topic is not about databases, or types of tables, but please could you help me telling me if the official application with innodb tables? I get the error: "/ / if the 'id' in the URL is not valid, or if there is no 'id' value, display an error" There is a difference between the auto increment field in a table myisam / innodb? Or is it that I delete something in the code that I can see ? Thank you very much for your time and reading my question / case. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted February 9, 2012 Author Report Share Posted February 9, 2012 Unfortunately I know very little about innodb, so that's something you'll probably need to research on your own. Sorry! Quote Link to comment Share on other sites More sharing options...
karlosantana Posted February 9, 2012 Report Share Posted February 9, 2012 I have been going nuts looking for a php lesson like this, plain english and I was able to follow along every step of the way. Thanks to you I'm now learning! I have a question though, users. How could you bridge this with something lets say joomla (only because thats my next everest ) so that only registered users could view it. Would I have to build this as a module and assign individual user levels?? I have actually made this script able to put new users into joomla, using only this script! Thankyou! Thanks again Karlos Quote Link to comment Share on other sites More sharing options...
rup2020 Posted February 16, 2012 Report Share Posted February 16, 2012 Hello! Dear Friend This was an awesome tutorial which I have used to create a database system . There I have a problem ?? Please see attachment!! I want to edit the "feedback" field without leaving the view page. I want to edit on preview table. How can I do that. I have modify your code look like that .... <?php require_once('auth.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>Member Index</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <center> <img src="./images/sonali.jpg" height="100px" width="100px"/> </center> <div align="center"> <p> <h1> Welcome TO Sonali Bank Limited</h1><br /> <h2><?php echo $_SESSION['SESS_FIRST_NAME'];?></h2> <h2><?php echo $_SESSION['SESS_LAST_NAME'];?></h2> <h3>BRANCH CODE : <?php echo $_SESSION['SESS_MEMBER_LOGIN'];?></h3> </div> <p><a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a> | <a href="user-view-admin.php">View ALL</a> | <a href="user-view-paginated.php">View Paginated</a></p> <?php //This code is for SONALI BANK ONLY // connect to the database include('user-connect-db.php'); include('config.php'); //check user name // get the records from the database if ($result = $mysqli->query("SELECT * FROM sblnrat WHERE brcode = $_SESSION[sESS_MEMBER_LOGIN] Order by id")) { // display records if there are records to display if ($result->num_rows > 0) { // display records in a table echo "<table align='center' border='1' cellpadding='10'>"; // set table headers echo "<tr><th>SL</th><th>PON</th><th>TRA NO.</th><th>TRA DT</th><th>BR-CODE</th><th>BR-NAME</th><th>BF-NAME</th><th>BF-A/C</th><th>AMT</th><th>Feed Back</th></tr>"; while ($row = $result->fetch_object()) { // set up a row for each record echo "<tr>"; echo "<td>" . $row->id . "</td>"; echo "<td>" . $row->pon . "</td>"; echo "<td>" . $row->trano . "</td>"; echo "<td>" . $row->tradt . "</td>"; echo "<td>" . $row->brcode . "</td>"; echo "<td>" . $row->brname . "</td>"; echo "<td>" . $row->bfname . "</td>"; echo "<td>" . $row->bfac . "</td>"; echo "<td>" . $row->amt . "</td>"; echo "<td>" . $row->feedback . "</td>"; echo "<td>".' <form action="insert.php?id='. $row->id . '" method="post"> <select name="feedback"> <option selected="selected">'.$row->feedback.'</option> <option value="Paid">02</option> <option value="NotPaid">05</option> </select> <input type="submit" name="submit" value="Update" /> </form>'."</td>"; echo "<td><a href='user-records.php?id=" . $row->id . "'>Edit</a></td>"; echo "</tr>"; } echo "</table>"; } //if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli->error; } // close database connection $mysqli->close(); ?> <br /> </body> </html> When I want to submit feed back the insert.php was nor working ????? can any one make a insert.php for me or any java script solution or other else!!! Quote Link to comment Share on other sites More sharing options...
rup2020 Posted February 18, 2012 Report Share Posted February 18, 2012 Hello! Dear ADMIN This was an awesome tutorial which I have used to create a database system . There I have a problem ?? Please see attachment!! I want to edit the "feedback" field without leaving the view page. I want to edit on preview table. How can I do that. I have modify your code look like that .... <?php require_once('auth.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>Member Index</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <center> <img src="./images/sonali.jpg" height="100px" width="100px"/> </center> <div align="center"> <p> <h1> Welcome TO Sonali Bank Limited</h1><br /> <h2><?php echo $_SESSION['SESS_FIRST_NAME'];?></h2> <h2><?php echo $_SESSION['SESS_LAST_NAME'];?></h2> <h3>BRANCH CODE : <?php echo $_SESSION['SESS_MEMBER_LOGIN'];?></h3> </div> <p><a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a> | <a href="user-view-admin.php">View ALL</a> | <a href="user-view-paginated.php">View Paginated</a></p> <?php //This code is for SONALI BANK ONLY // connect to the database include('user-connect-db.php'); include('config.php'); //check user name // get the records from the database if ($result = $mysqli->query("SELECT * FROM sblnrat WHERE brcode = $_SESSION[sESS_MEMBER_LOGIN] Order by id")) { // display records if there are records to display if ($result->num_rows > 0) { // display records in a table echo "<table align='center' border='1' cellpadding='10'>"; // set table headers echo "<tr><th>SL</th><th>PON</th><th>TRA NO.</th><th>TRA DT</th><th>BR-CODE</th><th>BR-NAME</th><th>BF-NAME</th><th>BF-A/C</th><th>AMT</th><th>Feed Back</th></tr>"; while ($row = $result->fetch_object()) { // set up a row for each record echo "<tr>"; echo "<td>" . $row->id . "</td>"; echo "<td>" . $row->pon . "</td>"; echo "<td>" . $row->trano . "</td>"; echo "<td>" . $row->tradt . "</td>"; echo "<td>" . $row->brcode . "</td>"; echo "<td>" . $row->brname . "</td>"; echo "<td>" . $row->bfname . "</td>"; echo "<td>" . $row->bfac . "</td>"; echo "<td>" . $row->amt . "</td>"; echo "<td>" . $row->feedback . "</td>"; echo "<td>".' <form action="insert.php?id='. $row->id . '" method="post"> <select name="feedback"> <option selected="selected">'.$row->feedback.'</option> <option value="Paid">02</option> <option value="NotPaid">05</option> </select> <input type="submit" name="submit" value="Update" /> </form>'."</td>"; echo "<td><a href='user-records.php?id=" . $row->id . "'>Edit</a></td>"; echo "</tr>"; } echo "</table>"; } //if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli->error; } // close database connection $mysqli->close(); ?> <br /> </body> </html> When I want to submit feed back the insert.php was nor working ????? can any one make a insert.php for me or any java script solution or other else!!! I have create the insert.php file but it not work can nay one solve this matter.... <?php // connect to the database include("user-connect-db.php"); /*------------------------------- EDIT RECORD --------------------------------*/ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_POST['submit'])) { if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $feedback = htmlentities($_POST['feedback'], ENT_QUOTES); // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE sblnrat SET feedback= ? WHERE id=?")) { $stmt->bind_param("si", $feedback, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: member-view.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error...............!!!!!!!"; } } // close the mysqli connection $mysqli->close(); ?> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted February 19, 2012 Author Report Share Posted February 19, 2012 I would suggest looking at something like http://www.appelsiini.net/projects/jeditable and a tutorial on that script: http://www.programmingfacts.com/jquery-editable-edit-placeinline/ Quote Link to comment Share on other sites More sharing options...
rup2020 Posted February 20, 2012 Report Share Posted February 20, 2012 I would suggest looking at something like http://www.appelsiini.net/projects/jeditable and a tutorial on that script: http://www.programmingfacts.com/jquery-editable-edit-placeinline/ Thank you very much !!!!!!! I have solved my problem.. Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.