Jump to content

Is this secure


dropfaith

Recommended Posts

Im trying to make this as secure as possible this is used anytime i pull data from the db

 

<?php
  if (!isset($_GET['needoffer'])) {
    header('Location: /rideshare/');
  }
?>

 

		<?php
// includes
include("../template/conf.php");


// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// generate and execute query

	if(!is_array($_GET['needoffer']))
{
	$needoffer = mysql_escape_string(trim($_GET['needoffer']));
	$query = "SELECT * FROM rideshare  WHERE needoffer = '$needoffer'";

	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
}
else
{
//special circumstance
	$query = "SELECT * FROM rideshare";
	$result = mysql_query($query) or die("Error in query: $query. " . mysql_error());
}





// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>

and anything upon insert runs thru this

 

$Contact = mysql_real_escape_string(trim(stripslashes($_POST['Contact'])));

 

just trying to find out the best practise to secure things cause everytime i ask someone to test the security they find a hole somehow

Link to comment
https://forums.phpfreaks.com/topic/129051-is-this-secure/
Share on other sites

better option then get? is all dynamic so get was the only thing i thought would work well..

 

links end up like this

 

http://lawrenceguide.org/literature/bygenre.php?Genre=Adventure

http://lawrenceguide.org/artist/profile.php?Name=test

 

im fine with updating everything to  a more secure format would take awhile but its worth it to secure this

Link to comment
https://forums.phpfreaks.com/topic/129051-is-this-secure/#findComment-669048
Share on other sites

i think get is fine... was just mentioning that you need to be validating the GET string on every page to make sure you are more secure. You could use regular expressions to validate for only characters numbers and quotation marks etc...

 

Link to comment
https://forums.phpfreaks.com/topic/129051-is-this-secure/#findComment-669057
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.