Jump to content

Archived

This topic is now archived and is closed to further replies.

miron

Big problem for a beginer

Recommended Posts

hi. I have made a login system and I can make it connect to mysql, but when the page that comes up after the login should display something for each username that I register. I mean, If i want to register joe, then when he logs in he should see a message that i have composed for him. I will give you the login page and the display page. Can you figure out what is wrong?

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php

include 'config.php';

ob_start();
echo "<center><font size\"2\" face=\"Tahoma\">The login system</font></center><br>";
echo "Login..<br>";
echo "<form action=\"./login.php\" method=\"POST\">";
echo "Name: <br><input type=\"text\" name=\"username\"><br>";
echo "<input type=\"submit\" value=\"Login!\">";
echo "</form>";

$connection = @mysql_connect($hostname, $user, $pass)
or die(mysql_error());
$dbs = @mysql_select_db($database, $connection) or
die(mysql_error());

$sql = "SELECT * FROM `users` WHERE username = '$_POST[username]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
$num = @mysql_num_rows($result);

if ($num != 0) {
$cookie_name = "auth";
$cookie_value = "fook";
$cookie_expire = "0";
$cookie_domain = $domain;

setcookie($cookie_name, $cookie_value, $cookie_expire, "/", $cookie_domain, 0);
header ("Location: main.php?ptusertx=" . $_POST[username]);

ob_end_flush();

exit;
}
?>[/quote]
This was the login page.

Here is the page after...
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
include 'config.php';


$connection = @mysql_connect($hostname, $user, $pass)
or die(mysql_error());
$dbs = @mysql_select_db($database, $connection) or
die(mysql_error());

$sql = "SELECT text FROM `users` WHERE username = '$ptusertx'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
$text=mysql_result($result,0,"text");
?>

<html>

<head>
<title></title>
</head>

<body>
<center>

<?php
echo "Salut $ptusertx !!!<br>";
echo "Text: $text";
?>

</body>

</html>[/quote]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.