synchro_irl Posted February 19, 2008 Share Posted February 19, 2008 Hey guy hope yer all well im trying to get my php to work witin my css template, the php works perfectly on its own, but i am not sure how to have it within the css template. heres teh code down below. any help wood be great thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Pluralism Description: A two-column, fixed-width template fit for 1024x768 screen resolutions. Version : 1.0 Released : 20071218 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Search4Trade</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper" style="width: 961px; height: 564px"> <div id="wrapper2"> <div id="header"> <div id="logo"> <h1>search4trade.net</h1> </div> <div id="menu"> <ul> <li><a href="#">Search </a></li> <li><a href="#">Forum</a></li> <li><a href="#">Register</a></li> <li><a href="#">About Us</a></li> <li><a href="#">Contact</a></li> </ul> </div> </div> <div id="page"> <div id="content" style="width: 766px; height: 205px"> <div class="post"> <h2 class="title"><a href="#">Welcome to Search4Trade</a></h2> <div class="entry"> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> </div> </div> </div> </div> </div> </div> <p style="text-align: center">(c) 2008 Search4Trade.net</p> </body> <?php // Connects to your Database mysql_connect("localhost", "root", "clio172") or die(mysql_error()); mysql_select_db("mydatabase") or die(mysql_error()); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['username']; $pass = $_COOKIE['password']; $check = mysql_query("SELECT * FROM mytable WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: submit.html"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database $check = mysql_query("SELECT * FROM mytable WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <ahref=register.php>Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area include("search1.html"); } } } else { // if they are not logged in ?> <?php } ?> </html> Quote Link to comment Share on other sites More sharing options...
rameshfaj Posted February 19, 2008 Share Posted February 19, 2008 Did u have the file extension as .php? Quote Link to comment Share on other sites More sharing options...
synchro_irl Posted February 19, 2008 Author Share Posted February 19, 2008 when i save teh file as .php, i get the following message: The requested URL /login1.php was not found on this server. but when i use the .html extension its says : Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Login1.php on line 92 but i never got an error here before. heres the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Pluralism Description: A two-column, fixed-width template fit for 1024x768 screen resolutions. Version : 1.0 Released : 20071218 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Search4Trade</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper" style="width: 961px; height: 564px"> <div id="wrapper2"> <div id="header"> <div id="logo"> <h1>search4trade.net</h1> </div> <div id="menu"> <ul> <li><a href="#">Search </a></li> <li><a href="#">Forum</a></li> <li><a href="#">Register</a></li> <li><a href="#">About Us</a></li> <li><a href="#">Contact</a></li> </ul> </div> </div> <div id="page"> <div id="content" style="width: 766px; height: 205px"> <div class="post"> <h2 class="title"><a href="#">Welcome to Search4Trade</a></h2> <div class="entry"> <?php // Connects to your Database mysql_connect("localhost", "root", "clio172") or die(mysql_error()); mysql_select_db("mydatabase") or die(mysql_error()); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['username']; $pass = $_COOKIE['password']; $check = mysql_query("SELECT * FROM mytable WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: submit.html"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database $check = mysql_query("SELECT * FROM mytable WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area include("search1.html"); } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?> </div> </div> </div> </div> </div> </div> <p style="text-align: center">(c) 2008 Search4Trade.net</p> </body> </html> Quote Link to comment Share on other sites More sharing options...
trq Posted February 19, 2008 Share Posted February 19, 2008 You don't close your call to die(). This.... die('That user does not exist in our database. should be.... die('That user does not exist in our database.'); Quote Link to comment Share on other sites More sharing options...
synchro_irl Posted February 19, 2008 Author Share Posted February 19, 2008 perfect, worked a dream!!! thanks so much for that. my next problem is the layout, since i added the php, the webpages is looking like this: but should be looking like this: Quote Link to comment Share on other sites More sharing options...
thebadbad Posted February 19, 2008 Share Posted February 19, 2008 I would say your link to the stylesheet is broken? And do you want PHP in your stylesheet? Quote Link to comment Share on other sites More sharing options...
Sulman Posted February 19, 2008 Share Posted February 19, 2008 FYI, it's not advisable to to show your username and password in a post... Quote Link to comment Share on other sites More sharing options...
synchro_irl Posted February 19, 2008 Author Share Posted February 19, 2008 I would say your link to the stylesheet is broken? And do you want PHP in your stylesheet? yes i need the php in the page Quote Link to comment Share on other sites More sharing options...
thebadbad Posted February 19, 2008 Share Posted February 19, 2008 You are really unclear. The page?? Do you mean your CSS file? Quote Link to comment 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.