Jump to content

Big problem for a beginer


miron

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.