PHP - Securing Pages
Hello everyone, this is my first post. This isn't just a simple post and leave, I'm looking to expand into this community and learn as much as I can. Well on to the problem at hand!
I decided to start with something simple as a login page and now want to expand it to make it fully functional. Code: (index.html) [Select] <html> <head> <title>Deadnode.com</title> <LINK href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div style=width:150px;height:80px;position:absolute;left:40%;top:35%; margin-left:-135px;margin-top:-50px;"> <div class="sidebox"> <div class="boxhead"><h2>Login Required</h2></div> <div class="boxbody"> <form method="post" action="check.php"> <center><table> <tr><td><font face="verdana,arial" size=-1>User:</td><td><input type="text" name="user"></td></tr> <tr><td><font face="verdana,arial" size=-1>Pass:</td><td><input type="text" name="pwd"></td></tr> <tr><td><font face="verdana,arial" size=-1> </td><td><font face="verdana,arial" size=-1><input type="submit" value="Login"></td></tr> </table></center> </form> </div> </div> </body> </html> Code: (function.php) [Select] <?php function check() { $admin="test"; $pass="test"; if ( $_POST["user"] == $admin & $_POST["pwd"] == $pass) { header('Location: output.php'); } else { header('Location: index.html'); } } ?> Code: (check.php) [Select] <?php require('function.php'); check(); ?> This is just the code in it originally form; completely functional. I tried to use start_session() in my check() function. I know I should be using cookies, but I haven't gotten that far yet. Is it possible to use my check function as a way to block pages? I tried inserting the same code that is in check.php onto a html page, but I've had no luck with it redirecting back to my index.html page. Similar TutorialsI posted this in the CSS forum with no success. Hello all! I have been trying for days to get HTML purifier to filter my CSS, with no prevail at all. Do you guys recommend any certain way to filter user inputted CSS style sheets? Any filter to use? Hey everyone, I am trying to secure php includes and I wrote the following lines: Code: [Select] <?php $dir=scandir('.'); if (in_array('copyright.php',$dir)) { include('copyright.php'); } else { echo 'That page could not be found'; } ?> Is this code secure enough, can anyone help me improve it? Thanks in advance. I was told that my login page could easily be manipulated to set themselves as my username (Mod Justin), giving them powers. How can I further secure my website's use of cookies? Quote I just visited your site as you - Mod Justin, simply by setting a 'user' cookie for your domain with your username in it. Your login code is NOT effective at stopping anyone or any bot script from impersonating any of the users, even impersonating you. My login code: http://pastebin.com/cBLybGKq Any possible solution to this? Hello,
I am quite new to the php and website scene and i am trying to find the best way to validate and sterilize my $_post the way i have come up with is
$id = filter_var(mysql_real_escape_string($_POST['id']),FILTER_SANITIZE_NUMBER_INT);or $id = mysql_real_escape_string($_POST['id']); $id1 = filter_var($id,FILTER_SANITIZE_NUMBER_INT);which will be the best way to do it or is there a better way. Thanks Edited by AdamHull12, 04 October 2014 - 11:15 AM. Hey, I'm wondering how to secure my unsubscribe link. Currently the link looks something like this delete.php?id=6 the number is the field id of the email address. However when if someone then changed the to delete.php?id=5 then the email address with the id 5 would be deleted. I have tried doing an MD5 but it doesn't seem to work. Any ideas I've been trying all day. Hello, I'm writing an application that will have to interact with my webserver and it will be using php to input data into the database and retrieve from as well. However, I'm not sure what is the best approach on securing my database from people sniffing while using my application. The only thing that I can do that is coming to mind is try to use a unique key as a password and have one of my GET vars be that password, but that is easily sniff-able. What can I do to secure my database and prevent people from filling up my databases if they sniff out my password key? Is there any kind of encryption I can use that will defeat this? Hey everyone, I am new to PHP and I want to learn how to secure a PHP session properly. I wrote a few lines, but I don't know if it's secure enough. Code: [Select] <?php session_start(); if (isset($_SESSION['exists'])) { if ($agent != $_SERVER['HTTP_USER_AGENT']) { session_unset(); session_destroy(); session_regenerate_id(True); } } else { $_SESSION['exists']=1; $agent=$_SERVER['HTTP_USER_AGENT']; session_regenerate_id(); } ?> Can anybody help me correct or improve my code? Thanks in advance. Hi my website offers the users to buy the videos. But the hackers are stealing my video links through view source. So there any option to hide my video links in view source and firebug etc..My videos are comign from amazon. and we are using JW Players to play the videos The methods i have tried.. 1)Encode and decode the urls still the embed tag displays the complete path in firebug. 2)Amazon provide signed url(temporary url)-Still have some problem in this.. 3)call the video through ajax call. Still the complete HTML code will be displayed in the firebug. please check here i have attached the firebug sample how it displays the code. Here we can find the complete video path in file: attribute in embed tag Is there any to hide the urls Hi, I want to secure my AJAX routines which use the POST method. I want to prevent people from posting to my method with their own program/script. I have read about making a random seed that the server knows to expect from authorized AJAX sources. What is the basic code for doing this? Hello, I wish to secure the PayPal form button. As my button is used on a subscription website, I don't want people changing the parameters and code needs to be hidden from peering eyes with firebug for instance. I have heard that you can pass the data to PayPal be given a CMD URL in return and you simply forward the user to such URL. Anyone know of this? - or another method? The button manager is not acceptable as the values will change in the hidden fields. George. I am building an e-commerce site and have a security question. My Payment Gateway has given me "Log-In ID" and "Transaction Key" that I use to log in to their server to submit payments. What is a *reasonable* way to protect this information? I have a VPS with root access, although I'm relying on using sFTP and the Plesk Control Panel since I don't know SSH yet. Can I just store my "Log-In ID" and "Transaction Key" in a php file outside of my Web Root and include it? Would that be secure enough for now? Thanks, Debbie I've just gotten back into re learning web development, I have created a contact form however my server is forcing me to use SMTP which will require me to have a config include with my details inside. How do I ensure nobody can open the files in the browser? I have heard of putting the files outside of the webroot or using htaccess files however the passive aggressive answers I got from stack over flow didn't tell me HOW to implement them. The files are Form.HTML Bin/config.php Bin/mail.php Any help is appreciated. I tried searching but came up empty handed, hoping you guys can give me some assistance. I have a login script that I would like to lock down a little from flooding. What is the easiest way to do this? Something that will restrict the IP if the script encounters x amount of failed attempts in x amount of minutes. Thanks! If I store a value in a hidden form control, and then use that as a means to pass the value to another PHP script, could that cause any security issues?
This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=346762.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=358932.0 like if I'm displaying a hundred entries , my website will be super long in length so I wanna break those hundred entries into maybe like 12 per page . Then click next page or the page number to view the next 12. hi guy's i have on one page select from table, and i don't know how to limit showing content from database on 3, and rest to make number under it and when i click on that number next 3 is showen? Something like on forum when you have more topics then you can show, on botom of page are showen numbers (links). Can some explain me how to do this? i put in while loop something like this Code: [Select] while ($prom = mysql_fetch_object($res) and $i<3) and now it is limited on showing first 3, my problem is showing next 3, and if there is more how to split it on 3 per page? Hello everyone, I am new to this site and new to working with php. I am wondering about a code that i could use for splash pages for members to be able to use them. I have the splash pages set up already but have not been able to figure out how to code it so that all the members of the site can use them to promote the site. Any help would be great thanks. Aaron Hey all, I've a problem with including of my pages. When I do choose lotto on index.php , I do get the page and also can choose how many roster I want. But I can't see my lotto results, because it does refresh to the index.php again. How can I fix this problem ? this is the code of index.php: Code: [Select] <?php echo '<table class="achtergrond" border="1">'; echo '<tr><td colspan="3">'; /* Keuzelijst tonen */ echo '<center><form action="'.$_SERVER['php_self'].'" method="POST"><select name="test">'; echo '<option selected>Kies een formulier</option></center>'; echo '<option value="1">Lotto</option>'; echo '<option value="2">Euromillions</option>'; echo '</select>'; echo '<button type="submit" name="knop">OK</button>'; echo '</form>'; echo '</td></tr>'; /* Als er op de knop gedrukt is , voer het lottoformulier uit*/ if(isset($_POST['knop'])) { echo '<tr><td>'; echo $waarde; /* variabel $waarde een waarde insteken via keuzelijst */ switch($_POST['test']) { case 1; include('formulieren/lotto.php'); case 2; include('formulieren/euromillions.php'); } echo '</td></tr>'; echo '</table>'; } ?> and this is the code of lotto.php: Code: [Select] <?php echo '<table class="achtergrond">'; echo '<tr><td colspan="3">'; /* Keuzelijst tonen */ echo '<center><form action="'.$_SERVER['php_self'].'" method="POST"><select name="lotto">'; echo '<option selected>Kies aantal rooster</option></center>'; echo '<option value="1">2 roosters</option>'; echo '<option value="2">4 roosters</option>'; echo '<option value="3">6 roosters</option>'; echo '<option value="4">8 roosters</option>'; echo '<option value="5">10 roosters</option>'; echo '<option value="6">12 roosters</option>'; echo '</select>'; echo '<button type="submit" name="knop1">OK</button>'; echo '</form>'; echo '</td></tr>'; /* Als er op de knop gedrukt is , voer het lottoformulier uit*/ if(isset($_POST['knop1'])) { /* variabel $waarde een waarde insteken via keuzelijst */ switch($_POST['lotto']) { case 0; $waarde2 = 0; break; case 1; $waarde2 = 1; break; case 2; $waarde2 = 2; break; case 3; $waarde2 = 3; break; case 4; $waarde2 = 4; break; case 5; $waarde2 = 5; break; case 6; $waarde2 = 6; break; }... |