-
[Help]
Surely that wouldn't return the current userid to delete though? Anyway I tried: // this is in a new file delete.php <?php if(isset($_POST['user_id']) && ctype_digit($_POST['user_id'])) { $sql = "DELETE FROM `afb2_accounts` WHERE `account_id` = '{$_POST['user_id']}' LIMIT 1"; } ?> and this in the index: <th> <form method="post"> <input type="image" src="/img/delete_user32.ico" title="Delete" name="user_id" value="delete.php"/> </form> </th> Just seems to refresh the index though. Edit: Found that I closed the if where I connect to the database and forgot to connect back. It works now, thanks guys. Thanks SniderDK for the code!
-
Anybody need a Forrst invite?
Thank you!
-
Anybody need a Forrst invite?
I joined this forum to be part of the community and contribute what I can and get help if I need it. Someone was offering an invite so you may as well ask, since I've heard a lot about Forrst.
-
[Help]
Thanks for the help and fast reply! Thought to security isn't a high priority at the moment as only I can access the file. Back to the code you posted though, I tried it and it doesn't seem to delete the user... I've done this: <th> <form method="post"> <input type="image" src="/img/delete_user32.ico" title="Delete" name="user_id" value="<?php echo $row['user_id'];?>"/> </form> </th> if(isset($_POST['user_id']) && ctype_digit($_POST['user_id'])) { $sql = "DELETE FROM `afb2_accounts` WHERE `account_id` = '{$_POST['user_id']}' LIMIT 1"; } Just seems to refresh the index.php
-
[Help]
/* Sorry about the title, I named it [Help] meaning to but something in after I entered what I wanted to post but forgot about the title and now I can't edit it. */ Here is my current code for returning SQL user's with all information on that user. <!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=utf-8" /> <style = "text/css"> table.center {margin-left:auto; margin-right:auto;} Body {font-family:Segoe UI;} fieldset { border: 1px solid #FFFFFF; width: 20em margin-bottom: 10px align:center } </style> <title>Return SQL</title> </head> <body background="blue-bg.png"> <form id="form1" name="form1" method="post" align="center" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <h1 align="center">Return SQL Database</h1> <center>Return mySQL users: <input type="submit" name="submit" id="submit" value="Submit" /></center> <?php /* // If "99.99.99.999" is shown // text has been replaced */ $userip = ($_SERVER['REMOTE_ADDR']); $ip = '99.99.99.999'; if($userip == $ip) { echo "<center><b>IP:</b> <font color=\"#00FF08\">" . $_SERVER['REMOTE_ADDR'] . "</font></center>"; } else if($userip !== $ip) { echo "<center><b>IP:</b> <font color=\"red\">" . $_SERVER['REMOTE_ADDR'] . "</font></center>"; } ?> </fieldset> </form> <?php /* // If "99.99.99.999" is shown // text has been replaced */ if($_POST['submit'] && $userip == $ip) { $sql = mysql_connect('99.99.99.999', '99.99.99.999', '99.99.99.999'); mysql_connect('99.99.99.999', '99.99.99.999', '99.99.99.999') or die('Error'); mysql_select_db('99.99.99.999', $sql); ?> <table border="1" cellpadding="3" cellspacing="3" class="center"> <tr> <th>ID</th> <th>Name</th> <th>Username</th> <th>Password</th> <th>Is Disabled?</th> <th>Is Admin?</th> <th>Theme?</th> </tr> <td align="center"> <?php $query = mysql_query('select * from `afb2_accounts`'); while ($row = mysql_fetch_array($query)){ $id = $row['account_id']; $name = str_replace("99.99.99.999", "FakeUser", $row['account_name']); $uname = str_replace("99.99.99.999", "FakeUser", str_replace("99.99.99.999", "FakeUser", $row['account_username'])); $pass = str_replace("99.99.99.999", "FakeUser", str_replace("99.99.99.999", "FakeUser", $row['account_password'])); $isd = $row['account_disabled']; $isa = str_replace("yes", "no", $row['account_admin']); $theme = $row['theme']; ?> <tr> <th><?php echo $id;?></th> <th><?php echo $name;?></th> <th><?php echo $uname;?></th> <th><?php echo $pass;?></th> <th><?php echo $isd;?></th> <th><?php echo $isa;?></th> <th><?php echo $theme;?></th> </tr> <?php }}else if($_POST['submit'] && $userip !== $ip){echo"<h2 align=\"center\">Error, you are not from a valid IP address</h2>";} //ending if's ?> </td> </br> </table> </body> </html> What I'm looking to do is add a column on the table to delete that users row along with all the information connected to that user. I am aware of the DELETE FROM statement but I'm not sure how to make sure it is deleting the corresponding user that the row the delete button is on. Any help is appreciated.
- Hey
-
Return Directory
Ahh, I see. Thanks for sharing that
-
-
Return Directory
Thank you! I will take what you said into consideration and implement it. The script is only for me to be honest, but if I want to get better using PHP I should make the best script I can! One thing, do you mean I should replace: if ($_SESSION['autherised']) { // with if (isset($_SESSION['autherised'])) { If so, that doesn't work.
-
Hey
Hey guys. In the past year I've become really interested in web development, mainly PHP. I got to a point where I was getting stuck on ideas of what to make thus making my ever expanding knowledge of PHP not expand. So after being recommended by a friend I thought I would sign up here, seems like a good and friendly site with genuinely nice people (not like the gaming forums). I also own my own site, which mainly caters to the needs of the Playstation 3 and Xbox 360 world (http://deany95.com). I originally started modding the Xbox 360 and after a while I was using VB and C# to create apps for others to mod. I know a decent amount of C# and that really got me interested in PHP, not sure exactly how, but it just did. Anyway, after me going on, I just want to say hey and I hope I can contribute to this forum.
-
Anybody need a Forrst invite?
If possible could I get one? E-Mail: josh@deany95.com I know I'm new but I'm really want to advance on web development and I've tried so many times to get in but get no response and only 1 vote haha. I made, http://deany95.co.uk/development/ & http://deany95.co.uk/development/math/ & http://deany95.co.uk/development/old_projects/imgup/ Thanks
-
Return Directory
Basically I know with some hosting companies return all the files and folders as a default page if no index is present. Well mine doesn't so I started creating a simple script to return the files and folders, and it just went on from there really to a more advanced "directory viewer". A friend of mine (djekl) helped with the form showing if password and/or IP is correct or not. <?php /* * Code placed here is coded by djeklDevelopments * * [iNFORMATION] * * This coe here is a nice and simple PHP session code. * It is used so that you (the developer) can authenticate on this page, and simply * move about your site authenticated. Its used to prevent unatutherised access to * anything you may not want people to see. * * [uSAGE] * * In this section I will give you the code to use on any and all protected pages! */ // This code is only for the login page! session_start(); function killSession() { if(isset($_SESSION['autherised'])) { // destroy session by unset() function unset( $_SESSION['autherised'] ); // destroy the session session_destroy(); } @header('Location: index.php'); // Location to login page! (best to use a full url inc http/s) exit; } ?> <!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=utf-8" /> <title>Directory Viewer</title> <style = "text/css"> Body {font-family:Segoe UI;} </style> </head> <body> <h1 align=center>Directory Viewer</h1> <?php // login false to reset password box // change to true if you want to make true only once $_SESSION['autherised'] = false; $userip = ($_SERVER['REMOTE_ADDR']); // Enter your IP below $ip = '28.24.24.289'; $password = $_POST['password']; // eneter your password below $pword = 'password'; if ($userip == $ip || $_POST['submit'] && $password == $pword) { //login successful $_SESSION['autherised'] = true; if($userip == $ip) { $_SESSION['IP'] = true; // Autherised via IP } else { $_SESSION['IP'] = false; // Autherised via Password } } else { if($_POST['submit'] && $password != $pword) { echo "<center>The password you entered is incorrect.</center><BR>"; } echo "<center><form id=\"form1\" name=\"form1\" method=\"post\" action=\"index.php\"><label for=\"res\">Please enter a password to continue: </label><input type=\"password\" name=\"password\" /><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit\" /></form></center>"; } date_default_timezone_set('Europe/London'); $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); $date = strtolower(date("F")); $logfile = $_SERVER['DOCUMENT_ROOT'] . $directory_self . $date . "_log.html"; if ($_SESSION['IP']) { $logdetails = date("j F Y, g:i a") . ' : ' . "<font color=\"#00FF08\">" . str_replace($ip, 'MyIP', $userip) . "</font>"; } else { $logdetails = date("j F Y, g:i a") . ' : ' . "<font color=\"red\">" . $userip . "</font>"; } $fp = fopen($logfile, "a"); fwrite($fp, $logdetails); fwrite($fp, "<br>"); fclose($fp); if ($_SESSION['autherised']) { // enter the path to your directory $path = "/homepages/domain.com/dev/"; $dir_handle = @opendir($path) or die("Unable to open $path"); while (false !== ($file = readdir($dir_handle))) { /* // if you want to return the go back folder if (strpos($file, '..') !== false) { //Return Go Back Folder echo "<center><table border=\"1\" width=\"440\" cellpadding=\"3\" cellspacing=\"3\" class=\"center\"><tr><th>Go Back</th></tr><td align=\"center\"><b><a href=\"/dev/$file\">$file</a></b></td></table></center>"; } */ // file and folders you don't want to be returned if($file == "." || $file == ".." || $file == "index.php" || $file == $date . "_log.html") continue; if (strpos($file, '.') === false) { echo "<center><table border=\"1\" width=\"440\" cellpadding=\"3\" cellspacing=\"3\" class=\"center\"><tr><th>Directory</th></tr><td align=\"center\"><b><a href=\"/dev/$file\">$file</a></b></td></table></center>"; } else { echo "<center><table border=\"1\" width=\"440\" cellpadding=\"3\" cellspacing=\"3\" class=\"center\"><tr><th>File</th></tr><td align=\"center\"><b><a href=\"/dev/$file\">$file</a></b></td></table></center>"; } } closedir($dir_handle); } if ($_SESSION['autherised']) { echo "<br><center><a href=\"" . $date . "_log.html\">Click here to view the log</a></center><br>"; echo "<center></br><b>IP:</b> <font color=\"#00FF08\">" . $userip . "</font></center>"; } else { echo "<center></br><b>IP:</b> <font color=\"red\">" . $userip . "</font></br>You're not from a verified IP address, most of the actions you try to complete on pages after this may not work.</center>"; } ?> </body> </html> If there are any problems when using this let me know, or if you have anyway I can improve it let me know. Make sure you change the a href=""'s. Hope you like my first post on the site