heshan Posted August 27, 2010 Share Posted August 27, 2010 Hi guys, I want something to be clarified. The supervisor of my system is responsible for approving accounts. When he logged into the system he should be able to view the customer records based on customer ID. That is when he types the relevant customer ID and clicks on search button the relevant record is displayed in a form. That part is OK. Thereafter he should approve the account by clicking on "Approve Account" button. I want to know how can he make sure relevant customer_id is approved or not. customer table includes fields of, customer_id, nic, full_name, name_with_initials, address, contact_number, gender. I want to whether i have add an extra field to my customer table saying "approves status" or whatever. Can anyone give me a suggestion?? Thanks, Heshan Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/ Share on other sites More sharing options...
Shp0ngl3 Posted August 27, 2010 Share Posted August 27, 2010 make a new field named "approved" and use 0/1 to define if the user is approved or not.. 0 beeing not approved and 1 beeing approved... then you can easily do like SELECT * FROM table WHERE approved=0 to list all customers that needs to be approved Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104277 Share on other sites More sharing options...
brown2005 Posted August 27, 2010 Share Posted August 27, 2010 Hi, If you have say another field. account_status enum '0','1' with 0 being unapproved and 1 being approve, when someone clicks on the button, it will change the id you selected to 1, then you can have a little approval message which says which one is approved so say... ID 1 Status Approved Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104279 Share on other sites More sharing options...
heshan Posted August 27, 2010 Author Share Posted August 27, 2010 @Shp0ngl3, i made a query according to you. This is how it looks like. I want a message to be appeared as " Details have been successfully approved" How could i do that? <?php $connect=mysql_connect("localhost","root",""); mysql_select_db("bank",$connect) or die ("could not select database"); $query = "select* from customer where approved='0'"; mysql_query($query) or die(mysql_error()); $query = "UPDATE customer SET approved='1' WHERE approved='0'"; mysql_query($query) or die(mysql_error()); ?> @brown 2005, It is better to apply another field and state whether the account is approved or not. But i am confusing about that. Can you give me an example coding? Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104315 Share on other sites More sharing options...
Shp0ngl3 Posted August 27, 2010 Share Posted August 27, 2010 Try something like this <?php $connect=mysql_connect("localhost","root",""); mysql_select_db("bank",$connect) or die ("could not select database"); $query = "select * from customer where approved='0'"; mysql_query($query) or die(mysql_error()); $query = "UPDATE customer SET approved='1' WHERE approved='0'"; $result = mysql_query($query) or die(mysql_error()); if ($result) { echo "Details have been successfully approved"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104316 Share on other sites More sharing options...
litebearer Posted August 27, 2010 Share Posted August 27, 2010 this... $query = "UPDATE customer SET approved='1' WHERE approved='0'"; $result = mysql_query($query) or die(mysql_error()); would result in ALL customers being approved. its needs to be ... $query = "UPDATE customer SET approved='1' WHERE customer_id = '$the_particular_customer_id'"; $result = mysql_query($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104323 Share on other sites More sharing options...
heshan Posted August 27, 2010 Author Share Posted August 27, 2010 @ litebearer, you are right. i want something that to be done. I need to approve customers one by one. But this coding i made not worked.Can anyone help me out...... <?php $connect=mysql_connect("localhost","root",""); mysql_select_db("bank",$connect) or die ("could not select database"); if(isset($_POST['customer_id'])){ $customer_id=$_POST['customer_id']; $query = "SELECT * from customer WHERE approved='0'"; mysql_query($query) or die(mysql_error()); $query = "UPDATE * from customer WHERE customer_id='$customer_id'"; $result = mysql_query($query) or die(mysql_error()); if ($result) { echo "Customer details have been successfully approved"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104358 Share on other sites More sharing options...
litebearer Posted August 27, 2010 Share Posted August 27, 2010 Psuedo code... form page 1. connect to db 2. select all where not approved 3. loop thru results while($row = mysql_fetch_array[$result] { echo the customer name as a check box where the value of the check box is the cust-id end loop 4. when submit is entered go to process page process page check to see which check boxes were selected update those records display the customers that were updated Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104385 Share on other sites More sharing options...
heshan Posted August 29, 2010 Author Share Posted August 29, 2010 Now it is OK. Thanks everyone who help me out..... 8) Quote Link to comment https://forums.phpfreaks.com/topic/211859-how-to-approve-account-based-on-customer-id/#findComment-1104917 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.