jamesxg1 Posted January 22, 2009 Share Posted January 22, 2009 Hiya, Can anyone help me i need to make it so that my customers can click a button and it will preform this mysql query *UPDATE Users SET groupid = 'P' WHERE userid = '$id';* and then re-direct them to a specific page. Thanks James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/ Share on other sites More sharing options...
DeanWhitehouse Posted January 22, 2009 Share Posted January 22, 2009 We are not here to make your site bit by bit for you, please try and work it out on your own. http://tizag.com and http://w3schools.com are great places to learn php Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743497 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 We are not here to make your site bit by bit for you, please try and work it out on your own. http://tizag.com and http://w3schools.com are great places to learn php Ok thankyou , I like that Tizag. Thankyou James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743499 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 Ok iv looked but it still doesnt tell me how to make a button that will execute a db query :S, Any help people ?, Thanks James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743534 Share on other sites More sharing options...
DeanWhitehouse Posted January 22, 2009 Share Posted January 22, 2009 It won't have an exact tutorial on their for that but does have all the parts required. http://www.tizag.com/phpT/forms.php http://www.tizag.com/mysqlTutorial/mysqldelete.php Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743538 Share on other sites More sharing options...
limitphp Posted January 22, 2009 Share Posted January 22, 2009 Ok iv looked but it still doesnt tell me how to make a button that will execute a db query :S, Any help people ?, Thanks James. A button won't execute a query. You can make the button hit a page, and then that page does the update and then takes them to whatever page you want. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743540 Share on other sites More sharing options...
PFMaBiSmAd Posted January 22, 2009 Share Posted January 22, 2009 What exact part of this do you need help with? Your question is so general that the only way to answer it would be to do it for you and that is not what programming help forums are for. Do you have a specific part you need help with? What have you done so far? Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743549 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 What exact part of this do you need help with? Your question is so general that the only way to answer it would be to do it for you and that is not what programming help forums are for. Do you have a specific part you need help with? What have you done so far? Hiya, Well what i need is something that my customers can click and it will updat there groupid in the database, And i have created the page and tryed to create the code but im stuck!. James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743565 Share on other sites More sharing options...
Maq Posted January 22, 2009 Share Posted January 22, 2009 You need to get the id from somewhere, most likely a session, but here's a skeleton of how you can accomplish this. if(isset($_POST['butt')) { //execute query //redirect } ?> How do you have an online store and don't even know how to go about this? Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743570 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 You need to get the id from somewhere, most likely a session, but here's a skeleton of how you can accomplish this. <?php if(isset($_POST['butt')) { //execute query //redirect } ?> <html> <body> <input type="button" name="butt" value="update"> </body> </html> How do you have an online store and don't even know how to go about this? Hiya Maq, Thankyou for that and i dont i am a beginner im trying to make my own social network script im getting pretty far i just keep stalling on parts that i dont understand !, And i have copied the code you gave me and edited it is this correct <?php if(isset($_POST['butt')) { //execute query mysql_query("UPDATE Users SET groupid = 'P' WHERE userid = '$username'") //redirect (Location: logout.php) } ?> <html> <body> <input type="button" name="butt" value="update"> </body> </html> , Thankyou James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743574 Share on other sites More sharing options...
Maq Posted January 22, 2009 Share Posted January 22, 2009 Is it? What makes you think it's not? Does it work the way you want it to? Do you get errors? Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743577 Share on other sites More sharing options...
DeanWhitehouse Posted January 22, 2009 Share Posted January 22, 2009 Stop being lazy and try it, stealing script you don't understand wont get you anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743578 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 Is it? What makes you think it's not? Does it work the way you want it to? Do you get errors? Ok. I see you are getting annoyed with me i will close the thread. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743600 Share on other sites More sharing options...
Maq Posted January 22, 2009 Share Posted January 22, 2009 Is it? What makes you think it's not? Does it work the way you want it to? Do you get errors? Ok. I see you are getting annoyed with me i will close the thread. I don't know about everyone else but, I'm not getting annoyed... I'm just trying to push you in the right direction. We gave you the pseudo code, now as Blade already said, the pieces are out there you just have to put them together. There's probably a similar scenario to yours right here on phpfreaks. If we do all the work for you, you will never do any work for yourself because you will never learn. That's why this section is called PHP Help, not PHP we will code your CMS for free. The point is to try it yourself and come back with some code and questions for us to help you out with. P.S. - The section isn't closed, it's just marked as solved. Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743608 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 Is it? What makes you think it's not? Does it work the way you want it to? Do you get errors? Ok. I see you are getting annoyed with me i will close the thread. I don't know about everyone else but, I'm not getting annoyed... I'm just trying to push you in the right direction. We gave you the pseudo code, now as Blade already said, the pieces are out there you just have to put them together. There's probably a similar scenario to yours right here on phpfreaks. If we do all the work for you, you will never do any work for yourself because you will never learn. That's why this section is called PHP Help, not PHP we will code your CMS for free. The point is to try it yourself and come back with some code and questions for us to help you out with. P.S. - The section isn't closed, it's just marked as solved. Good luck! Thankyou Maq, I do try im just not very skilled i am undergoing tutorials thoe but the stuff i need done tutorials dont help! , heres what iv made of that code so far it had some errors in the $_POST area but all sorted <?php if(isset($_POST['terminate'])) //execute query mysql_query("UPDATE Users SET groupid = 'P' WHERE userid = '$username' "); //redirect header("Location:../login/logout.php"); ?> <html> <body> <input type="button" name="terminate" value="update"> </body> </html> Unfortunetly it still doesnt work it just redirect's me straight away without any of the querys done , But not to fear i will continue on my quest to sort it , If you have any ideas on why it just redirects please post would be much apreciated . Thanks guy's. James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743627 Share on other sites More sharing options...
DeanWhitehouse Posted January 22, 2009 Share Posted January 22, 2009 Where is $username defined and also you are comparing the username to the userid in the query. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743641 Share on other sites More sharing options...
Maq Posted January 22, 2009 Share Posted January 22, 2009 * This is not tested * You need to assign $username to something like Blade said, but this should be an error less example. if(isset($_POST['terminate'])) { $username = "user1"; $sql = "UPDATE Users SET groupid = 'P' WHERE userid = '$username'"; mysql_query($sql) or die(mysql_error()); header("Location: ../login/logout.php"); } ?> </pre> <form method="POST" action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>"> </form> <b Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743651 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 Where is $username defined and also you are comparing the username to the userid in the query. Sorry, Blade your totally are correct really sorry here iv edited it <?php if(isset($_POST['terminate'])) //execute query mysql_query("UPDATE Users SET groupid = 'P' WHERE username = '$username' "); //redirect header("Location:../login/logout.php"); ?> <html> <body> <input type="button" name="terminate" value="update"> </body> </html> Thanks for pointing that out. James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743653 Share on other sites More sharing options...
Maq Posted January 22, 2009 Share Posted January 22, 2009 You still need the variable $username to be assigned to something. In your sql statement you're comparing username to something that doesn't even exist. How do you know what username to UPDATE? Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743655 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 You still need the variable $username to be assigned to something. In your sql statement you're comparing username to something that doesn't even exist. How do you know what username to UPDATE? Oh. Well what i was trying to do was get it from the session and the varible for that is $username, This is the code so far <?php session_start(); require("../db/db.php"); //include database file require("../db/config.php"); //include configuration file require("../db/util.php"); isloggedin(); accessneeded("C"); ?> <?php if(isset($_POST['terminate'])) { $sql = "UPDATE users SET groupid = 'P' WHERE username = '$username'"; mysql_query($sql) or die(mysql_error()); header("Location: ../login/logout.php"); } ?> <html> <body> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="submit" name="terminate" value="update"> </form> </body> </html> James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743663 Share on other sites More sharing options...
DeanWhitehouse Posted January 22, 2009 Share Posted January 22, 2009 Does it work? Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743666 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 Does it work? Unfortunatly no. It just displays the button and once clicked it re-directs you. Unknown to why it dont work thoe :S, Im completely confused now , James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743675 Share on other sites More sharing options...
Maq Posted January 22, 2009 Share Posted January 22, 2009 Assuming you have already started the session, you can change your SQL statement to: $sql = "UPDATE users SET groupid = 'P' WHERE username = '{$_SESSION['username']}'"; Also, there's no point to have (lines 10 & 11): ?> Does it work? Unfortunatly no. It just displays the button and once clicked it re-directs you. Unknown to why it dont work thoe :S, Im completely confused now , James. So it just doesn't update the database? Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743679 Share on other sites More sharing options...
DeanWhitehouse Posted January 22, 2009 Share Posted January 22, 2009 Your code will just redirect any way unless their is a problem updating. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743685 Share on other sites More sharing options...
jamesxg1 Posted January 22, 2009 Author Share Posted January 22, 2009 Assuming you have already started the session, you can change your SQL statement to: $sql = "UPDATE users SET groupid = 'P' WHERE username = '{$_SESSION['username']}'"; Also, there's no point to have (lines 10 & 11): ?> <?php Does it work? Unfortunatly no. It just displays the button and once clicked it re-directs you. Unknown to why it dont work thoe :S, Im completely confused now , James. So it just doesn't update the database? WORKS!!!, Thankyou so much guy's!, Remeber my username because i WILL get better at PHP one day and i will do something back for you's once again THANKYOU!!. Life savers!. Many Many Thanks James. Quote Link to comment https://forums.phpfreaks.com/topic/141996-solved-php-terminate-account-help/#findComment-743689 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.