Robert Elsdon Posted May 5, 2008 Share Posted May 5, 2008 This is the code i want to add to the login page: 1.) echo "<body bgcolor=\"#505050\" text=\"#000000\" link=\"#363636\" vlink=\"#363636\" alink=\"#d5ae83\">"; i want Number 1.) added to number 2.) 2.) <?php session_start(); // dBase file include "dbConfig.php"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `dbUsers` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`=PASSWORD('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: home.php"); } else { // Login not successful die("Sorry, You have enterd a wrong Username or Paswword please try again and be more carefull with your spelling!"); } } else { echo "<center>"; echo '<font size="2" face="verdana" color="#3d3d3d">'; echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"> "; echo "Password: <input type=\"password\" name=\"password\" size=\"15\"> "; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; echo "</font>"; } ?> <?php $text = "http://ultimateravers.net/register.php"; echo ereg_replace("http://([a-zA-Z0-9./-]+)$", "<a href=\"\\0\">\\0", $text); ?> All help is apreciated! Link to comment https://forums.phpfreaks.com/topic/104184-where-would-i-add-this-code-to-the-login-page-code/ Share on other sites More sharing options...
joecooper Posted May 5, 2008 Share Posted May 5, 2008 this should work... <?php session_start(); // dBase file include "dbConfig.php"; echo "<body bgcolor=\"#505050\" text=\"#000000\" link=\"#363636\" vlink=\"#363636\" alink=\"#d5ae83\">"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `dbUsers` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`=PASSWORD('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: home.php"); } else { // Login not successful die("Sorry, You have enterd a wrong Username or Paswword please try again and be more carefull with your spelling!"); } } else { echo "<center>"; echo '<font size="2" face="verdana" color="#3d3d3d">'; echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"> "; echo "Password: <input type=\"password\" name=\"password\" size=\"15\"> "; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; echo "</font>"; } ?> <?php $text = "http://ultimateravers.net/register.php"; echo ereg_replace("http://([a-zA-Z0-9./-]+)$", "<a href=\"\\0\">\\0", $text); ?> Link to comment https://forums.phpfreaks.com/topic/104184-where-would-i-add-this-code-to-the-login-page-code/#findComment-533354 Share on other sites More sharing options...
Robert Elsdon Posted May 5, 2008 Author Share Posted May 5, 2008 thanks very much your post helped me and worked! ;D Link to comment https://forums.phpfreaks.com/topic/104184-where-would-i-add-this-code-to-the-login-page-code/#findComment-533355 Share on other sites More sharing options...
Robert Elsdon Posted May 5, 2008 Author Share Posted May 5, 2008 ok im sorry it did work but when i log in this error comes up? Warning: Cannot modify header information - headers already sent by (output started at /home/ultimate/public_html/login.php:7) in /home/ultimate/public_html/login.php on line 34 http://ultimateravers.net/register.php Link to comment https://forums.phpfreaks.com/topic/104184-where-would-i-add-this-code-to-the-login-page-code/#findComment-533357 Share on other sites More sharing options...
peranha Posted May 5, 2008 Share Posted May 5, 2008 This should get it working <?php session_start(); // dBase file include "dbConfig.php"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `dbUsers` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`=PASSWORD('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: home.php"); } else { echo "<body bgcolor=\"#505050\" text=\"#000000\" link=\"#363636\" vlink=\"#363636\" alink=\"#d5ae83\">"; // Login not successful die("Sorry, You have enterd a wrong Username or Paswword please try again and be more carefull with your spelling!"); } } else { echo "<center>"; echo '<font size="2" face="verdana" color="#3d3d3d">'; echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"> "; echo "Password: <input type=\"password\" name=\"password\" size=\"15\"> "; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; echo "</font>"; } ?> This will only output the body if there is an error. you cannot have header information output if there has already been an output which was being done with the body tag at the beginning. Link to comment https://forums.phpfreaks.com/topic/104184-where-would-i-add-this-code-to-the-login-page-code/#findComment-533395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.