miron Posted June 24, 2006 Share Posted June 24, 2006 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--]<?phpinclude '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) ordie(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--]<?phpinclude 'config.php';$connection = @mysql_connect($hostname, $user, $pass)or die(mysql_error());$dbs = @mysql_select_db($database, $connection) ordie(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><?phpecho "Salut $ptusertx !!!<br>";echo "Text: $text";?></body></html>[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/12789-big-problem-for-a-beginer/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.