ispravno je sledece:
Code:
<?php
define('PRIMARY_DB_NAME', 'database1');
define('PRIMARY_DB_USERNAME', 'user');
define('PRIMARY_DB_PASSWORD', 'pass');
define('PRIMARY_DB_HOSTNAME', 'localhost');
define('ADMIN_EMAIL', '
[email protected]');
define('VOTE_THRESHOLD', 10);
class mysql_link {
function mysql_link($DB_HOST,$DB_USERNAME,$DB_PASSWORD,$DB_NAME){
$this->link=@mysql_pconnect($DB_HOST,$DB_USERNAME,$DB_PASSWORD);
if (!$this->link) {
echo('Database server is down - symptom: invalid username, password or server URI');
echo(' <a href="mailto:'.ADMIN_EMAIL.'?subject=Database is down!">Click here to email to administrator that site is down</a>. Press the back button, please. Sorry for the inconvenience.');
die();
} // end if
$this->exists=@mysql_select_db($DB_NAME,$this->link);
if (!$this->exists) {
echo('Database server is down - symptom: site cannot select database specified');
echo(' <a href="mailto:'.ADMIN_EMAIL.'?subject=Database is down!">Click here to email to administrator that site is down</a>. Press the back button, please. Sorry for the inconvenience.');
die();
} // end if
} // end function
function close() {
if ($this->link) @mysql_close($this->link);
$this->link=FALSE;
$this->exists=FALSE;
} // end function
function query($query) {
$this->query=FALSE;
if($this->exists){
$this->query=@mysql_query($query,$this->link);
if ($this->query) {
$this->querynumber++;
$this->sqldump=$this->sqldump."/n".$query;
return $this->query;
} // end if
else {
echo"Problematic SQL query ::: <br /><br />".$query."<br /><br />Please <a href=\"mailto:".ADMIN_EMAIL."?subject=Bug in SQL at domain ".$_SERVER["SERVER_NAME"]."\">email to administrator</a> that there are technical difficulties";
die();
} // end else
} // end if
} // end function
} // end class
class login {
...
Da ne bude lele majko kad tabela valja da se prosiri... HTML u jedan falj, PHP i SQL u deseti
ovo ti je dobar primer:
Code:
<?pho
include "globals.php";
include "connect.php";
include "start.php";
include "prolog.php";
include "head";
include "body";
include "footer";
?>
globals php nek ti je gore
// connect.php
<?php
$db_link=new mysql_link (PRIMARY_DB_HOSTNAME, PRIMARY_DB_USERNAME, PRIMARY_DB_PASSWORD, PRIMARY_DB_NAME);
?>
//start php
session_start();
header("Cache-control: private");
if ((isset($_POST["username"]))&&(isset($_POST["oass"]}) {
$login=new login(addslashes($_POST["username"),addslashes($_POST["password"]);
}
if (isset($_GET["page"]) {
switch ($_GET["page"]) {
case "contact":
Global_target="contact";
break;
case "products";
Global_target="products";
break;
//ili iz baze da dovlaxcis, ali je svejedno
// head
<HTML>
<HEAD>
<TITLE>
<?php if ($login->logged) {
echo $login->username.", dobrodosli na Elitesecurity.org";
} // end if
else {
echo "Dobrodosli na Elitesecurity.org";
} // end else
?></TITLE>
</HEAD>
</BODY>
.....
itd
sve ostalo NE VALJA UOPSTE!!! Imas da rodis mecku ako nesto valja izmeniti.
[Ovu poruku je menjao bojan_bozovic dana 02.08.2006. u 11:06 GMT+1]