Jump to content


Photo

PHP MySql Dreamweaver


This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1 Massive_Attack

Massive_Attack
  • Members
  • 2,103 posts

Posted 03 May 2005 - 18:12

Moze li mala pomoc oko PHP MySql i Dreamweaver-a?
Naime radi se o User Authentication Script-u koji pravim.
Sve dobro sljaka ali desava se sledece: da kada idem na sign up new user, popunim trazene podatke...name, e-mail, choose user name, choose pass..., kroz dreamweaver sam podesio u insert record da kada se trazeni podaci popune i pritisne Register da usera prebacuje na Login stranicu...(dotle radi) Kada na Login stranici upisem trazeni user i pass nece da me pusti na Member stranu nego ostaje na toj istoj! Takodje je i tu podeseno da ako je Pass ispravan da usera pusta na member stranu!
Database mi je sigurno dobro odradjena jer se u njoj pojavljuju trazeni podaci kada se novi korisnik registruje i zasto ne radi Login? Takodje i Text Field nosi isto ime kao i u database... nadam se da me razumeju oni koji se malo vise kontaju u dinamicke web sajtove i web aplikacije
Any Suggest? :lol:

#2 incognito

incognito
  • Members
  • 7,771 posts

Posted 03 May 2005 - 19:15

Suggestion - izlistaj ovde tvoju PHP skriptu i tvoju HTML strukturu, pa mozda mozemo da pomognemo... Ovako moze biti par miliona razloga...

#3 Massive_Attack

Massive_Attack
  • Members
  • 2,103 posts

Posted 03 May 2005 - 19:42

Allrighty Then :lol:

Login forma

<?php require_once('../../Connections/mysql.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();

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

if (isset($_POST['userName'])) {
$loginUsername=$_POST['userName'];
$password=$_POST['userPassword'];
$MM_fldUserAuthorization = "userPassword";
$MM_redirectLoginSuccess = "restricted.php";
$MM_redirectLoginFailed = "sorry.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_mysql, $mysql);

$LoginRS__query=sprintf("SELECT userName, userPassword, userPassword FROM login WHERE userName='%s' AND userPassword='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $mysql) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {

$loginStrGroup = mysql_result($LoginRS,0,'userPassword');

//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;

//register the session variables
session_register("MM_Username");
session_register("MM_UserGroup");

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR...ml4/loose.dtd">
<html>
<head>
<title>Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form ACTION="<?php echo $loginFormAction; ?>" name="form1" method="POST">
<table width="222" border="1" cellspacing="0" bordercolor="#000000">
<tr>
<td width="68">user name </td>
<td width="144"><input name="userName" type="text" id="userName"></td>
</tr>
<tr>
<td>password</td>
<td><input name="userPassword" type="password" id="userPassword"></td>
</tr>
<tr>
<td><a href="registration.php">sign up</a> </td>
<td><input type="submit" name="Submit" value="login"></td>
</tr>
</table>
</form>
</body>
</html>

Sign Up new user forma

<?php require_once('../../Connections/mysql.php'); ?>
<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="taken.php";
$loginUsername = $_POST['userName'];
$LoginRS__query = "SELECT userName FROM login WHERE userName='" . $loginUsername . "'";
mysql_select_db($database_mysql, $mysql);
$LoginRS=mysql_query($LoginRS__query, $mysql) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO login (userName, userPassword, userMail) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['userName'], "text"),
GetSQLValueString($_POST['userPassword'], "text"),
GetSQLValueString($_POST['userMail'], "text"));

mysql_select_db($database_mysql, $mysql);
$Result1 = mysql_query($insertSQL, $mysql) or die(mysql_error());

$insertGoTo = "login.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR...ml4/loose.dtd">
<html>
<head>
<title>Sign Up New User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<p>
<input name="userMail" type="text" id="userMail">
e-mail </p>
<p> <input name="userName" type="text" id="userName">
user name </p>
<p> <input name="userPassword" type="password" id="userPassword">
password
</p>
<p>
<input type="submit" name="Submit" value="Register">
</p>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>

#4 IkKan

IkKan
  • Members
  • 6 posts

Posted 29 December 2006 - 13:49

Imam skoro isti problem. Napravio sam neku web aplikaciju u dreamweaver-php-u
i ne mogu da osposobim sezonu. Umrezen sam sa dosta ljudi. Apach i baza se nalaze na mom racunaru(localhost-u). Pokusao sam na 1000 nacina, ali ne vredi. Sta mislite u cemu je problem?

NEKA MI NEKO POMOGNE sad.gif

#5 Massive_Attack

Massive_Attack
  • Members
  • 2,103 posts

Posted 29 December 2006 - 14:24

Daj jos neki detalj! Konkretno o kavoj aplikaciji je rec?

#6 IkKan

IkKan
  • Members
  • 6 posts

Posted 29 December 2006 - 15:31

Radi se o Blogu. LogIN skripta je jako slicna ovoj tvojoj, sem u dizajnu. Inace, baza radi sasvim lepo. LogIN radi kada na pocetnoj iskljucim Restrict Access To Page, kada je ukljucen, ne prebacuje me na pocetnu stranu, vec na LogIN fail stranu. I nema sanse da dobijem vrednost sezonskih varijabli.

#7 maksas

maksas
  • Members
  • 1,625 posts

Posted 29 December 2006 - 15:42

QUOTE(IkKan @ 29 Dec 2006, 15:31)
Radi se o Blogu. LogIN  skripta je jako slicna ovoj tvojoj, sem u dizajnu.  Inace, baza radi sasvim lepo. LogIN radi kada na pocetnoj iskljucim Restrict Access To Page, kada je ukljucen, ne prebacuje me na pocetnu stranu, vec na LogIN fail stranu. I nema sanse da dobijem vrednost sezonskih varijabli.


Na koji nacin startujes sesije? U php kodu, pozovi f-ju error_reporting(E_ALL); i pogledaj da li ti nakon toga prijavljuje neke greske vezane za session promenljive. wink.gif I jos nesto. Kako pristupas session promenljivama?

#8 IkKan

IkKan
  • Members
  • 6 posts

Posted 21 May 2007 - 13:38

Opet pomoc...
Potreban mi je neki php sign up user script za , koji provera ispravnost podataka kao sto su validan e-mail, username koji ne pocinje brojem... i jos svasta nesto... ja cu ga vec modifikovati po svojoj potrebi. Ako imate neki slican izlistajte ga ovde.

Masiv, nadam se da si resio problem sa login stranama, ako nisi, javni mogu da ti pomognem.

#9 maksas

maksas
  • Members
  • 1,625 posts

Posted 21 May 2007 - 14:09

CODE
<?

  function checkEmail($email) {
    $pattern = "/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9_\.\-]+\.[a-zA-Z0-9_\.\-]+$/";
    if (preg_match($pattern, $email)) {
      echo "email OK";
    }
    else {
      echo "bad email";
    }
  
  }

  function checkUsername($username) {
    $pattern = "/^[a-zA-Z_].+$/";
    if (preg_match($pattern, $username)) {
      echo "username OK";
    }
    else {
      echo "invalid username";
    }
  
  }

  checkUsername("00peraperic");
  checkEmail("dfs@dfs.com");

?>


F-je checkUsername() i checkEmail() pozivas nakon prosledjivanja podataka sa forme.
U zavisnosti od toga sta ti zatreba igraj se sa $pattern promenljivima, tj. regularnim izrazima.
Pozdrav! smile.gif

#10 IkKan

IkKan
  • Members
  • 6 posts

Posted 21 May 2007 - 15:33

Hvala laugh.gif

#11 IkKan

IkKan
  • Members
  • 6 posts

Posted 20 June 2007 - 10:03

Dreamweaver poludeo!!!! mad.gif

Da li je neko imao slican problem i zna kako da ga resim???
Koristim svoj racunar kao testing server tj. na njemu sljakaju apache i mysql server, i sa njima je sve u redu, vec sam radio neke aplikacije, i sve to funkcionise kako treba.
Medjutim, poceo sam da radim nesto novo i trebalo bi uraditi onaj graficki deo u dreamweaver-u. Kada probam da definisem dreamweaver sajt prilikom testiranja konekcije, on mi prikaze sledecu poruku:
"Dreamweaver cannot use the prefix you entered to
display live data. Please double-chack your site
configuration or click on Help.... (HTTP Error:12029)
"
a uneti prefix je http://localhost - ovo je do sada funkcionisalo unsure.gif

mad.gif Nije problem u engleskom jeziku, samo apache funkcionise, localhost u browseru radi, ali ga dreamweaver iz nekog razloga "ne vidi"... mad.gif

Naravno, probao sam opcijom da skinem dreamweaver, pa ga instaliram opet, ali ni to nije pomoglo...

Imate li predloge????? blink.gif