Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Php/MySql projekat, par pitanja

[es] :: Web aplikacije :: Php/MySql projekat, par pitanja

[ Pregleda: 1559 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Serbiankum
Srbija

Član broj: 54947
Poruke: 240
*.adsl-a-1.sezampro.yu.

Sajt: www.drvoumomdvoristu.com


Profil

icon Php/MySql projekat, par pitanja04.03.2009. u 15:47 - pre 183 meseci
Radim jedan mali projekat za fax, medjutim posto nemam mnogo iskustva sa php/my sql trebaju mi neke informacije.

U pitanju je izmisljeni sajt za automobile. Znaci administrator se loguje na svoj account i ima mogucnost da dodaje nove slike automobila, opis o kolima itd.

Cilj te mini web aplikacije je bezbednost.

Za pocetak sam napravio registration, login, log out forme kao i restricted strane.

Posto je akcenat na zastiti, za pocetak kako te forme da testiram na sql injection?

Inace aplikaciju pravim u Dreamweaveru CS4 i koristim vec gotov kod koji dreamweaver izgenerise.

Ovo je ceo kod koji je izgenerisao za stranicu login:

Code:

<?php require_once('Connections/registracija.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_registracija, $registracija);
$query_rsLogin = "SELECT username, password FROM registracija";
$rsLogin = mysql_query($query_rsLogin, $registracija) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "success.php";
  $MM_redirectLoginFailed = "not.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_registracija, $registracija);
  
  $LoginRS__query=sprintf("SELECT username, password FROM registracija WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $registracija) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;          

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>




Okacicu i bazu. Trenutno u njoj je samo jedna tabela registracija sa poljima Username(PK), password, status.
Okacio sam i login.php stranicu

Link za bazu i login stranicu(zauzima samo 1 kb):
http://rapidshare.com/files/20...6/baza_i_login_strana.rar.html
 
Odgovor na temu

Serbiankum
Srbija

Član broj: 54947
Poruke: 240
*.adsl-a-1.sezampro.yu.

Sajt: www.drvoumomdvoristu.com


Profil

icon Re: Php/MySql projekat, par pitanja04.03.2009. u 22:00 - pre 183 meseci
neki komentar?

Cilj mi je samo da testiram formu na sql injection. Bazu sam okacio kako bi videli tabelu i kolone.
Znaci koji sql injection kod ubaciti i kako?
 
Odgovor na temu

cveticmilan
System administrator
Beograd

Član broj: 105312
Poruke: 161
*.beocity.net.

Sajt: www.nb.rs


+8 Profil

icon Re: Php/MySql projekat, par pitanja21.03.2009. u 18:00 - pre 182 meseci
Dokle si stigao sa ovim projektom? I ja radim isto za fax pa me zanima dokle si stigao ...
 
Odgovor na temu

[es] :: Web aplikacije :: Php/MySql projekat, par pitanja

[ Pregleda: 1559 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.