BerkayAta 6 Posted March 3, 2014 Share Posted March 3, 2014 I want to add Account Freeze pages in my homepage. For example : http://kingdommt2.com/index.php?s=dondur Account : Sanane3152 Password : 123456789 This script is : http://pastebin.com/j29ECscP User is login to homepage. If user want to Account Freeze click to Account Freeze page. Select the date. For example : 1 day, 2 day, 3 day, 1 month, 2 month. When the time runs out account is available. How can I do this ? Thanks for everything. <!-- center column --> <div id="register" class="col-2"> <div class="content content-last"> <div class="content-bg"> <div class="content-bg-bottom"> <div class="textblock"> <h2>Hesabı Dondur</h2> <div class="inner-form-border"> <div class="inner-form-box"> <?PHP if(isset($_SESSION['user_admin']) && checkInt($_SESSION['user_admin']) && $_SESSION['user_admin']>=0) { echo ''; if(isset($_POST['banla']) && $_POST['banla']=='Hesabi Dondur') { $sqlCmd = "SELECT * FROM account.account WHERE id='".$getAdmin->id."' LIMIT 1"; $sqlQry = mysql_query($sqlCmd,$sqlServ); if(mysql_num_rows($sqlQry)>0) { $accData = mysql_fetch_object($sqlQry); $DeactiveCmd ="UPDATE account.account SET availDt='".$_POST['date']."' WHERE id='".$getAdmin->id."' "; if(mysql_query($DeactiveCmd,$sqlServ)) { echo'<div class="formNotification"><div></div> <p>Hesabınız Belirlediğiniz Süre Kadar Kapalı Kalacaktır. <strong><font color="#00FF00">Deaktive Olmuştur</font></strong> <br /> Anasayfaya Yönlendiriliyorsunuz.... </p></div>'; echo'<meta http-equiv="refresh" content="1; URL=index.php?s=logout"> '; } } } ?> <p>Aşağıdaki Sürelerden Birini Seçerek Dondurunuz <br> <font color="#FF0000">NOT: GERİ DÖNÜŞÜ OLMAZ</font></p> <form name="pwlostForm" id="pwlostForm" method="post" action="index.php?s=dondur"> <div> <label for="username"> Sürenizi Seçiniz: * <span class="thell"> <select name="date"> <?PHP foreach($Deactive AS $aKey => $aValue) { echo'<option value="'.$aValue.'">'.$aKey.'</option>'; } ?> </select> </span> </div> <input id="submitBtn" type="submit" name="banla" value="Hesabi Dondur" class="btn-big" /> <p></p> <script type="text/javascript"> $(function() { }); </script> </form> <p id="regLegend">* Zorunludur </p> <?php } else { echo "<div class='formNotification2'><div></div>Buraya Giris Yetkiniz Bulunmamaktadir<br> Lütfen Üye Girisi Yapiniz!!</p></div><div class='box clearfix'> <h2><img class='headicon' alt='' src='/img/alpha.gif' />Çıkış yapılıyor </h2> <img class='content-image' src='/img/img-content-01.jpg' /> <div class='textblock'> <p><meta http-equiv='refresh' content='0; URL=index.php'>Ana sayfaya yönlendirileceksiniz. Lütfen bekleyin...</p> </div> <div class='footer'></div> </div></div>"; } ?></div></div></div></div></div></div></div> Link to comment Share on other sites More sharing options...
Premium Shogun 4613 Posted March 4, 2014 Premium Share Posted March 4, 2014 If I understand well, you want a custom script coded for your homepage? Link to comment Share on other sites More sharing options...
Rumor 2625 Posted March 4, 2014 Share Posted March 4, 2014 looks like he wants temporary bans through an admin panel Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 4, 2014 Author Share Posted March 4, 2014 If I understand well, you want a custom script coded for your homepage? Yes. I gave the code doesn't work. Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 5, 2014 Author Share Posted March 5, 2014 Up Link to comment Share on other sites More sharing options...
Jancsi7 16 Posted March 5, 2014 Share Posted March 5, 2014 Hey! Create database table: CREATE TABLE `frozenaccounts` ( `id` int(5) NOT NULL AUTO_INCREMENT, `account_id` int(10) NOT NULL, `start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Create a dropdown menu, and a button. When he hit the button, read the data from the dropdown menu. Put the account id and start, end date to that table. On the index page of admins, create a code which checks if the end date equals with this date. In this case unblock the account. Why so serious? Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 5, 2014 Author Share Posted March 5, 2014 Hey! Create database table: CREATE TABLE `frozenaccounts` ( `id` int(5) NOT NULL AUTO_INCREMENT, `account_id` int(10) NOT NULL, `start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Create a dropdown menu, and a button. When he hit the button, read the data from the dropdown menu. Put the account id and start, end date to that table. On the index page of admins, create a code which checks if the end date equals with this date. In this case unblock the account. I don't understand with you. Please give me full codes. Link to comment Share on other sites More sharing options...
Jancsi7 16 Posted March 5, 2014 Share Posted March 5, 2014 This code will block the account. <?php if($_POST['submit']) { $delay = $_POST['delay']; $account_id = 1234; $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("INSERT INTO account.frozenaccounts (`account_id`, `start_date`, `end_date`) VALUES ($account_id, $start_date, $end_date)"); $sql02 = mysql_query("UPDATE account.account SET status = 'BLOCK' WHERE id = $account_id"); if($sql01 && $sql02) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="page1.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> This code will unblock the frozen chars which's delay has expired: <?php $now = date("Y-m-d H:i:s"); $query = mysql_query("SELECT * FROM account.frozenaccounts WHERE end_date <= $now"); if(mysql_num_rows($query) > 0) { //there are minimum one account which is frozen, and you have to unfroze it while($array = mysql_fetch_array($query)) { $accountid = $array['account_id']; $query2 = mysql_query("DELETE FROM account.frozenaccounts WHERE account_id = $accountid"); $query3 = mysql_query("UPDATE account.account SET status = 'OK' WHERE id = $accountid"); } } ?> If you won't open the page, where the second code is placed, it won't unfreeze the accounts. So you need to open it about once a day. If you open it for example 24 times a day, it will works perfectly, because if i freeze my account today at 8PM, and you will open it tomorrow at 7PM, my account won't unfreeze, so i have to wait to the next day. In my opinion 24 times per day would be ideal for this script. Why so serious? Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 5, 2014 Author Share Posted March 5, 2014 This code will block the account. <?php if($_POST['submit']) { $delay = $_POST['delay']; $account_id = 1234; $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("INSERT INTO account.frozenaccounts (`account_id`, `start_date`, `end_date`) VALUES ($account_id, $start_date, $end_date)"); $sql02 = mysql_query("UPDATE account.account SET status = 'BLOCK' WHERE id = $account_id"); if($sql01 && $sql02) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="page1.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> This code will unblock the frozen chars which's delay has expired: <?php $now = date("Y-m-d H:i:s"); $query = mysql_query("SELECT * FROM account.frozenaccounts WHERE end_date <= $now"); if(mysql_num_rows($query) > 0) { //there are minimum one account which is frozen, and you have to unfroze it while($array = mysql_fetch_array($query)) { $accountid = $array['account_id']; $query2 = mysql_query("DELETE FROM account.frozenaccounts WHERE account_id = $accountid"); $query3 = mysql_query("UPDATE account.account SET status = 'OK' WHERE id = $accountid"); } } ?> If you won't open the page, where the second code is placed, it won't unfreeze the accounts. So you need to open it about once a day. If you open it for example 24 times a day, it will works perfectly, because if i freeze my account today at 8PM, and you will open it tomorrow at 7PM, my account won't unfreeze, so i have to wait to the next day. In my opinion 24 times per day would be ideal for this script. I have got a problem. Notice: Undefined index: submit in C:AppServwwwYespagesfreeze.php on line 4 Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 5, 2014 Author Share Posted March 5, 2014 Up Link to comment Share on other sites More sharing options...
Premium Shogun 4613 Posted March 5, 2014 Premium Share Posted March 5, 2014 That's a Notice it's harmless... Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 6, 2014 Author Share Posted March 6, 2014 That's a Notice it's harmless... Shogun please give me full codes. Link to comment Share on other sites More sharing options...
Former Staff .InyaProduction 1138 Posted March 6, 2014 Former Staff Share Posted March 6, 2014 This is not a board for full codes. We want you to learn something while you manage to get i working. Without that helping would be senseless Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 6, 2014 Author Share Posted March 6, 2014 This is not a board for full codes. We want you to learn something while you manage to get i working. Without that helping would be senseless Why ? This thread is in the Beginner Zone. I don't to this. I need help. Link to comment Share on other sites More sharing options...
Former Staff .InyaProduction 1138 Posted March 6, 2014 Former Staff Share Posted March 6, 2014 We can help you best by showing you how to do it. Php error messages have a great documentation so you could use google aswell. but: <?php if(isset($_POST['delay'])) { $delay = mysql_real_escape_string($_POST['delay']); $account_id = 1234; //Here you have to add a code to get the logged in account_id $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("UPDATE account.account SET avialTd = DATE_ADD(NOW,INTERVAL ".$delay." DAY) WHERE id = $account_id"); if($sql01) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="freeze.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 6, 2014 Author Share Posted March 6, 2014 We can help you best by showing you how to do it. Php error messages have a great documentation so you could use google aswell. but: <?php if(isset($_POST['delay'])) { $delay = mysql_real_escape_string($_POST['delay']); $account_id = 1234; //Here you have to add a code to get the logged in account_id $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("UPDATE account.account SET avialTd = DATE_ADD(NOW,INTERVAL ".$delay." DAY) WHERE id = $account_id"); if($sql01) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="freeze.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> Thanks for give me codes but it doesn't work Link to comment Share on other sites More sharing options...
Former Staff .InyaProduction 1138 Posted March 6, 2014 Former Staff Share Posted March 6, 2014 You need to add the function to get the account_id at line 5 Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 6, 2014 Author Share Posted March 6, 2014 You need to add the function to get the account_id at line 5 Yes I know. This is : ($_SESSION['user_id']) But If user don't login the site click to freeze.php open the freeze.php Link to comment Share on other sites More sharing options...
Former Staff .InyaProduction 1138 Posted March 6, 2014 Former Staff Share Posted March 6, 2014 <?php if(isset($_SESSION['user_id']){ if(isset($_POST['delay'])) { $delay = mysql_real_escape_string($_POST['delay']); $account_id = $_SESSION['user_id']; $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("UPDATE account.account SET avialTd = DATE_ADD(NOW,INTERVAL ".$delay." DAY) WHERE id = $account_id"); if($sql01) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="freeze.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> <?php } else { echo "You dont have permission to go here"; } ?> Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 6, 2014 Author Share Posted March 6, 2014 <?php if(isset($_SESSION['user_id']){ if(isset($_POST['delay'])) { $delay = mysql_real_escape_string($_POST['delay']); $account_id = $_SESSION['user_id']; $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("UPDATE account.account SET avialTd = DATE_ADD(NOW,INTERVAL ".$delay." DAY) WHERE id = $account_id"); if($sql01) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="freeze.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> <?php } else { echo "You dont have permission to go here"; } ?> This is an error : Parse error: syntax error, unexpected '{' in C:AppServwwwYespagesfreeze.php on line 2 Link to comment Share on other sites More sharing options...
Premium Shogun 4613 Posted March 6, 2014 Premium Share Posted March 6, 2014 You don't say... delete line 18 Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 6, 2014 Author Share Posted March 6, 2014 You don't say... delete line 18 By then : Parse error: syntax error, unexpected '{' in C:AppServwwwYespagesfreeze.php on line 2 And I delete '{' it. If I login to site I see You dont have permission to go here Link to comment Share on other sites More sharing options...
Former Staff .InyaProduction 1138 Posted March 6, 2014 Former Staff Share Posted March 6, 2014 No dont delete line 18 o.o And you have to be logged in to access the site €dit: forgot to close one bracket <?php if(isset($_SESSION['user_id'])){ if(isset($_POST['delay'])) { $delay = mysql_real_escape_string($_POST['delay']); $account_id = $_SESSION['user_id']; $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("UPDATE account.account SET avialTd = DATE_ADD(NOW,INTERVAL ".$delay." DAY) WHERE id = $account_id"); if($sql01) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="freeze.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> <?php } else { echo "You dont have permission to go here"; } ?> Link to comment Share on other sites More sharing options...
BerkayAta 6 Posted March 6, 2014 Author Share Posted March 6, 2014 No dont delete line 18 o.o And you have to be logged in to access the site €dit: forgot to close one bracket <?php if(isset($_SESSION['user_id'])){ if(isset($_POST['delay'])) { $delay = mysql_real_escape_string($_POST['delay']); $account_id = $_SESSION['user_id']; $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("UPDATE account.account SET avialTd = DATE_ADD(NOW,INTERVAL ".$delay." DAY) WHERE id = $account_id"); if($sql01) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error"; } } ?> <form action="freeze.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> <?php } else { echo "You dont have permission to go here"; } ?> Okey. If user don't login the site says You dont have permission to go here but by then for example I selected 1 day and click to Submit an error. sql error How can I solve it ? Link to comment Share on other sites More sharing options...
Former Staff .InyaProduction 1138 Posted March 6, 2014 Former Staff Share Posted March 6, 2014 <?php if(isset($_SESSION['user_id'])){ if(isset($_POST['delay'])) { $delay = mysql_real_escape_string($_POST['delay']); $account_id = $_SESSION['user_id']; $start_date = date("Y-m-d H:i:s"); $end_date = date("Y-m-d H:i:s", strtotime("$delay day")); $sql01 = mysql_query("UPDATE account.account SET availlTd = DATE_ADD(NOW,INTERVAL ".$delay." DAY) WHERE id = $account_id"); if($sql01) { echo "Your account is blocked for $delay days.<br><br>"; } else { echo "sql error: ".mysql_error(); } } ?> <form action="freeze.php" method="POST"> <select name="delay"> <option value="1">1 day</option> <option value="2">2 day</option> <option value="3">3 day</option> <option value="7">1 week</option> </select> <input type="submit" name="submit" value="Submit"/> </form> <?php } else { echo "You dont have permission to go here"; } ?> Take this script and give me the error message thats showing Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now