| Autor | Zpráva | ||
|---|---|---|---|
| zdenek Profil |
#1 · Zasláno: 27. 2. 2011, 15:34:21
ahoj, jak to, že mi nefunguje toto?
<?php
$ok = $_REQUEST['ok'];
$username = $_REQUEST['username'];
include("include/fce.php");
include("include/config.php");
$action=$_GET[action];
switch($action){
case pass:
$ok = $_REQUEST['ok'];
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
if (isset($ok) && $ok==Send) {
connect();
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("username");
session_register("password");
header("location:home.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
}
}; break;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>RWS GmbH - ústředny</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="include/style.css">
</head>
<body>
<div align="center" id="neco">
<form method=POST <?php if(isset($ok)) echo "action=index.php?action=pass"; ?>>
<input type="text" name="username" value="<?php if(isset($username)) echo $username; ?>"><br><br>
<?php
if (isset($ok) && $ok==Send) {
connect();
$sql = "SELECT * FROM `users` WHERE `username` = '$username'";
$result = mysql_query($sql) or die(mysql_error());
$count= mysql_num_rows($result);
if ($count==1) {
echo "<input type=password name=password>";
echo "<br><br>";
}
else {
header("Location:index.php");
}
}
?>
<input type="submit" name="ok" value="Send">
</form>
</div>
</body>
</html> |
||
| johnl Profil |
#2 · Zasláno: 27. 2. 2011, 16:11:08
session_start();.?
|
||
| Martinek Profil * |
#3 · Zasláno: 27. 2. 2011, 16:22:03
|
||
| zdenek Profil |
#4 · Zasláno: 27. 2. 2011, 16:47:33 · Upravil/a: zdenek
Martinek:
právě proto se ptám, protože to nevím, a doufám v to, že mi někdo pomůže. |
||
| Zechy Profil |
#5 · Zasláno: 27. 2. 2011, 17:05:53
zdenek:
Možná bys moh říct, co to dělá, co to nedělá, nikdo to testovat nebude za tebe. |
||
| Tori Profil |
#6 · Zasláno: 27. 2. 2011, 19:42:09
ob_start() předpokládám voláte v některém includu?
Jinak ř.47 vám nevyhazuje náhodou Fatal error při použití break mimo switch? Přesměrování na ř.77 taky nebude fungovat ("headers already sent"). |
||
| panther Profil |
#7 · Zasláno: 28. 2. 2011, 10:58:56
zdenek:
měl bys nastudovat základy PHP. Kromě toho, co uvedla Tori tam máš spoustu syntaktických chyb - neuzavřené řetěžce do uvozovek. Zapni si výpis chybových hlášek, na syntaktické chyby tě PHP upozorní. |
||
|
Časová prodleva: 15 let
|
|||
0