Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Everything posted by DeanWhitehouse

  1. awardspace is good
  2. i have a piece of text in a variable(which people can edit) this text needs to be displayed down the page and should stay within the bounderies i set, but it isn't. here are some snippets from my code. $intro = "Welcome, this is a test of the sites features.Please go to the admin centre to cutomise the site."; <p class="welcome"><?php echo"$intro"; ?></p> p.welcome { color:#000; font-size:14px; text-align:center; margin-left:425px; margin-top:40px; width:400px; border:ridge #0000FF; }
  3. thanks, i didn't even think of that. The header still works,
  4. how can i get the echo's to display below the form instead of above, will i need to postition using CSS?? <div class="login"> <?php if ($_SESSION['is_valid'] == false) { if (isset($_POST['login'])) { $user_name = mysql_real_escape_string($_POST["user_name"]); $user_password = mysql_real_escape_string($_POST["user_password"]); $cookiename = forumcookie; $verify_username = strlen($user_name); $verify_pass = strlen($user_password); if ($verify_pass > 0 && $verify_username > 0) { $userPswd = md5($user_password); $userpwsd = sha1($userPswd); $sql = "SELECT * FROM $user WHERE user_name='$user_name' AND user_password='$userpwsd' LIMIT 1;"; $result = mysql_query($sql) or die(mysql_error() . " in $sql"); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); $s_userpass = serialize($userpass); $_SESSION['id_username'] = $row['user_name']; $_SESSION['id_user_password'] = $row['user_password']; $_SESSION['user_level'] = $row['userlevel']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['is_valid'] = true; if (isset($_POST['remember'])) { $checked = "checked='checked'"; setcookie("uname", $_SESSION['id_username'], time() + 86400*100); setcookie("userpw", $user_password, time() + 86400*100); setcookie("check",$checked, time() + 86400*100); } header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); } else { echo "Login failed. Username or Password are not correct."; } } else { ?> <p><font style="font-size:small;">You left required field(s) blank</p> <?php } } $server = str_replace("?logout","",$_SERVER['PHP_SELF']); ?> <table class="log_in"><form action="<?php echo "$server"; ?>" method="post"> <th>Welcome</th> <tr><td align="center">Username:</td></tr><tr><td align="center"><input type="text" name="user_name" size="16" value="<?php echo $_COOKIE['uname']; ?>" /><br /></td></tr> <tr><td align="center">Password:</td></tr><tr><td align="center"> <input type="password" name="user_password" size="16" value="<?php echo $_COOKIE['userpw'] ?>" /><br /></td></tr> <tr><td align="center"><input type="hidden" name="login" value="true"><input type="submit" value="Submit"></td></tr> <tr><td align="centre"><input type="checkbox" name="remember" <?php echo $_COOKIE['check'] ?>> Remember Me </td></tr><tr><td align="center"><a href="register.php">[Register]</a></td></tr><tr><td align="center"><a href="forgot_password.php">[Forgot Password?]</a></td></tr></table> </form> </div> <?php mysql_close(); } } ?> </div>
  5. I think i have coded this wrong , because when i submit the form and it echoes something the background above it moves down, this is my CSS body { background-color:#FFFFFF; font-family:"Times New Roman", Times, serif; font-style:normal; color:#990000; } /*link styles*/ /******************************************************************/ /*Title Links*/ a.title:link:{color:#FF0000; text-decoration:none;} a.title:visited {color:#0000FF; text-decoration:none;} a.title:hover {color:#FFFF00; text-decoration:none;} a.title:active {color:#00FF33; text-decoration:none;} /*Nav Bar Links*/ a.nav_bar:link:{color: #000066; text-decoration:none;} a.nav_bar:visited {color: #00FF33; text-decoration:none;} a.nav_bar:hover {color: #FF0000; text-decoration:underline;} a.nav_bar:active {color: #FFFF00;} /*Table Styles*/ /******************************************************************/ /*Title Bar*/ table.title { width:800px; table-layout:auto; height:100px; margin-left:225px; color:#FF0000; border:ridge #0000FF; text-align:center; background-color:#000000; } /*Logged In Section*/ table.logged_in { } /*Forum Main Page*/ table.forum_main { background-color:#0000CC; width:900px; } /**/ table.admin { border:#0000FF; } /*Div Styles*/ /******************************************************************/ /*Left Menu*/ div.left_bar { width:150px; border:ridge #0000FF; margin-left:225px; margin-top:20px; } /*Navigation Bar*/ div.nav_bar { table-layout:auto; } /*Login Menu(Side Bar)*/ div.login { } /*Time*/ div.clock { margin-left:615px; margin-top:-302px; width:179px; } /*background area under title*/ div.bg { margin-left:225px; margin-top:1px; background:repeat-x #00FF33; width:794px; height:20px; border-left:ridge #0000FF; border-right:ridge #0000FF; border-bottom:ridge #0000FF; } /*P Styles*/ /******************************************************************/ /*File Exists*/ p.exists { color:#FF00FF; font-size:xx-large; } /*Welcome Message*/ p.welcome { color:#000; font-size:14px; text-align:center; margin-left:10px; margin-right:30px; margin-top:40px; width:400px; border:#666666 thin solid; height:auto; } /*Disclaimer(footer)*/ p.disclaimer { font-size:small; } and this is my page, i have removed some of the PHP code, <div class="bg"><div class="clock"><?php echo gmdate('l, jS F Y');?> <span id="txt"></span></div></div> bg is the bit that moves, this is the link to the page, please say if you need to see more code http://deanwhitehouse.awardspace.co.uk/home.php when you click submit, when the fields blank the echo moves the bit above.
  6. i registered and got an error about the email and then when i logged in to the forum , it just says forum, nothing else
  7. anyway, back to my question, it is appearing on a different line, why is this?
  8. I would use sessions then check for the session on the page's you want protected
  9. what i had tried was this <script type="text/javascript"> function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); // add a zero in front of numbers<10 m=checkTime(m); document.getElementById('txt').innerHTML=h+":"+m+"; t=setTimeout('startTime()',500); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } </script>
  10. how am i lazy if i don't no how to do something??? as i did try changing it but i changed it wrong. Also this is dislaying on a second line, the code to display it, is this <?php echo gmdate('l, jS F Y');?><div id="txt"></div>
  11. I need a clock code that just shows hours and minutes and always updates, e.g you shouldn't need to refresh to show the current time. I was given this code a while ago <script type="text/javascript"> function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('txt').innerHTML=h+":"+m+":"+s; t=setTimeout('startTime()',500); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } </script> but this shows seconds, and i don't no how to change it.
  12. because it's ment to refer the user to the home page, and it is for a CMS so it has to be to there host. BTW i can follow directions, i just decide not to follow bad ones, as i thought your code done the same as mine http://mysite.co.uk/mysite.co.uk
  13. i tried this $url = $_SERVER['HTTP_HOST']; $log_out = $_SERVER['HTTP_HOST']."?logout"; $logout = str_replace($log_out,"",$url); header("Location:".$logout); but this does this http://mysite.co.uk/mysite.co.uk
  14. $logout = str_replace("?logout","",""); this is my code, i want to delete the ?logout, how can i do this(am i using the wrong code). example http://mysite.com/members?logout should change to this http://mysite.com/members
  15. Hi , i am making a site for someone, it is there portfolio and they are an artist, what would people recomend on how to do a photo album. Mysql? store links in there etc. or would i need JS any ideas?
  16. i think you want something like this site http://www.innovatorvillage.com/ sorry, i don't know how to do it, but it should give people the right idea
  17. just to say that i have already solved this on my own, and i know CSS and what i have works.
  18. yer, well it can be made more complex, and you can have it so it checks user level(or rights or whatever) and if you where admin, you can see the page properly.
  19. you would put an IF at the beggining of each page and IF($closed) { echo "site closed"; } else { rest of code } that won't work as it is, but should point you in the right direction
  20. erm, yer (please anyone correct me if i'm wrong)
  21. by doing a MySql query, and echoing the result in the <input value="<?php echo"$value"; ?>">
  22. Can someone tell me why this code, div.left_bar { position:absolute; left:200px; width:auto; } table.logged_in { top:; } table.left_bar { border:#00FF00 groove; background-color:#000000; top:120px; } is only adjusting the the width of this <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> and not this <table class="left_bar"><tr><td> <a class="nav_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <tr><td><a class="nav_bar" href="<?php echo "$home_page/forum.php"; ?>">Forum</a></td></tr> </table> what i want it to do, is the whole nav_bar all be the same width, so if the user has a long username the whole nav bar changes width not just part of it this is my whole code <div class="left_bar"> <?php /*Random Game Design: PHP Website Template/CMS Version 1 Copyright Dean Whitehouse, 2008*/ if (isset($_GET['logout'])) { setcookie("uname", $_SESSION['id_username'], time() - 86400*100); setcookie("userpw", $user_password, time() - 86400*100); setcookie("check",$checked, time() - 86400*100); session_unset(); session_destroy(); } if ($_SESSION['is_valid'] == true) { if ($_SESSION['user_level'] == 2) { ?> <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> <?php } if ($_SESSION['user_level'] == 1) { ?> <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php echo "$home_page"; ?>/admin/admin_centre.php">Admin Area</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> <?php } } else { require_once 'includes/db_connect.php'; if ($_SESSION['is_valid'] == false) { if (isset($_POST['login'])) { $user_name = mysql_real_escape_string($_POST["user_name"]); $user_password = mysql_real_escape_string($_POST["user_password"]); $cookiename = forumcookie; $verify_username = strlen($user_name); $verify_pass = strlen($user_password); if ($verify_pass > 0 && $verify_username > 0) { $userPswd = md5($user_password); $userpwsd = sha1($userPswd); $sql = "SELECT * FROM $user WHERE user_name='$user_name' AND user_password='$userpwsd' LIMIT 1;"; $result = mysql_query($sql) or die(mysql_error() . " in $sql"); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); $s_userpass = serialize($userpass); $_SESSION['id_username'] = $row['user_name']; $_SESSION['id_user_password'] = $row['user_password']; $_SESSION['user_level'] = $row['userlevel']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['is_valid'] = true; //change the session variable name to what you want, just remember it for all files if (isset($_POST['remember'])) { $checked = "checked='checked'"; setcookie("uname", $_SESSION['id_username'], time() + 86400*100); setcookie("userpw", $user_password, time() + 86400*100); setcookie("check",$checked, time() + 86400*100); } header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); } else { echo "Login failed. Username and Password did not match database entries."; } } else { echo "Form was not completed. Please go back and make sure that the form was fully completed."; } } $server = str_replace("?logout=true","",$_SERVER['PHP_SELF']); ?> <table bgcolor="#999999" align="right"><form action=" <?php echo "$server"; ?> " method="post"> <tr><td>Username: </td><td><input type="text" name="user_name" value="<?php echo $_COOKIE['uname']; ?>" /><br /></td></tr> <tr><td>Password:</td><td> <input type="password" name="user_password" value="<?php echo $_COOKIE['userpw'] ?>" /><br /></td></tr> <tr><td><input type="hidden" name="login" value="true"><input type="submit" value="Submit"></td></tr> <tr><td><input type="checkbox" name="remember" <?php echo $_COOKIE['check'] ?>> Remember Me </td></tr><tr><td><a href="register.php">[Register]</a></td></tr><tr><td><a href="forgot_password.php">[Forgot Password?]</a></td></tr></table> </form> <?php mysql_close(); } } ?> <?php require_once "includes/main.inc.php"; if ($_SESSION['is_valid'] == true){ ?> <table class="left_bar"><tr><td> <a class="nav_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <tr><td><a class="nav_bar" href="<?php echo "$home_page/forum.php"; ?>">Forum</a></td></tr> </table> <?php } else { ?> <a class="left_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <?php } ?> </div>
  23. I found another code, thanks for the replys
  24. Tried that, but i couldn't work out what to echo. can anyone help, this is the code the site suggested. if ( !isset($_SESSION['GMT_offset']) ) { $_SESSION['GMT_offset'] = 0; $_SESSION['GMT_offset_str'] = '+0:00'; } if ( isset($_GET['offset']) ) { $_SESSION['offset'] = $_GET['offset']; set_timezone($_GET['offset']); } function set_timezone( $offset ) { if ( $offset ) { $offset = -$offset; $_SESSION['GMT_offset'] = 60 * $offset; $GMT_offset_str = ( $offset > 0 ) ? '+' : '-'; $GMT_offset_str .= floor($offset / 60) . ':'; $GMT_offset_str .= (($offset % 60) < 10 ) ? '0' . $offset % 60 : $offset % 60; $_SESSION['GMT_offset_str'] = $GMT_offset_str; } } function format_datetime( $date ) { return ( date('d M Y g:ia', $date + $_SESSION['GMT_offset']) . ' GMT ' . $_SESSION['GMT_offset_str']); }
×
×
  • 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.