31-12-08, 19:31
|
# 6
|
חבר וותיק
|
ציטוט:
<html>
<head> <title> Connect </title> </head>
<body> <h1> connect to your editor </h1>
<?php
$connection = mysql_connect("DBNAME" , "USERNAME" , "PASSWORD") or die ("couldn't connect to the server");
mysql_select_db("DBNAME" , $connection ) or die ("couldn't connect to the database");
function connect() {
return <<<EOF
<FORM METHOD = "POST" ACTION="">
<INPUT TYPE="TEXT" NAME="USERNAME"> <br><br>
<INPUT TYPE="PASSWORD" Name="PASSWORD"> <br><br>
<INPUT TYPE="SUBMIT" VALUE="התחבר" NAME="SUBMIT">
</FORM>
EOF; // dollarconnect is a local variable withing the function connect, this won't get you anything except headaches
}
if(isset($_POST'['SUBMIT'])) { // what about closing the if?
$q = mysql_query ("SELECT * FROM 'table1' WHERE 'USERNAME' = '{$_POST['USERNAME']}' AND 'PASSWORD' = '{$_POST['PASSWORD']}' ");
$r = mysql_num_rows ($q);
if ($r == 1) // if there are couple of users with the same name and password?
{
echo 'you are online, and you can use the editor';
}
else {
echo 'bad username or password, please try again';
echo "<br />" . connect(); // since i changed connect() i should echo the returned value too
}
}
?>
</body>
</html>
|
have fun pal
__________________
|
|
|