Jump to content

Hooch

Members
  • Posts

    452
  • Joined

  • Last visited

Everything posted by Hooch

  1. After trying Hadien's code for a while I'm finding it as difficult to get what I want. If someone can have a look at the original code and question for help that would be terriffic. Thank you.
  2. Hi Hadien, thanks for taking the time to help me out. It's definitely got some errors, but I will try to figure it out.
  3. Hello all. I am trying to change this old script up a bit and need some help to get it 100% correct. I'm trying to create a weekly list of 3 people and their job lineup for each of those 3 weeks.Example:Week1:Job1:LesJob2:MikeJob3:DanWeek2:Job1:DanJob2:LesJob3:MikeWeek3:Job1:MikeJob2:DanJob3:LesThen repeat the job cycle from week 1 for eternity.If you check out my results so far at LINKY you can see it is simply repeating week#3 instead of starting over as week 1.Here is my code so far: <?PHP $var1 = 'Les'; $var2 = 'Dan'; $var3 = 'Mike'; $dayName = array(1 => "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); $monthName = array(1 => "January","February","March","April","May","June","July","August","September","October","November","December"); $monthDays = array(1 => 31,28,31,30,31,30,31,31,30,31,30,31); $row1 = array($var1,$var1,$var1,$var1,$var1,$var1,$var1,$var2,$var2,$var2,$var2,$var2,$var2,$var2,$var3,$var3,$var3,$var3,$var3,$var3,$var3); $row2 = array($var2,$var2,$var2,$var2,$var2,$var2,$var2,$var3,$var3,$var3,$var3,$var3,$var3,$var3,$var1,$var1,$var1,$var1,$var1,$var1,$var1); $row3 = array($var3,$var3,$var3,$var3,$var3,$var3,$var3,$var1,$var1,$var1,$var1,$var1,$var1,$var1,$var2,$var2,$var2,$var2,$var2,$var2,$var2); $now = time(); $nowd = date('j', $now); $nowm = date('F', $now); $nowy = date('Y', $now); $startdate = date(mktime(0,0,1,10,6,2013)); //Jan 1 2001 00:00:01 $getMonth = $_POST['month']; if($getMonth == '') $getMonth = date('n', $now); $getYear = $_POST['year']; if($getYear == '') $getYear = date('Y', $now); //$getMonth = $_POST['month']; if($getMonth == 0) { $getMonth = 12; $getYear = ($getYear - 1); } elseif($getMonth == 13) { $getMonth = 1; $getYear = ($getYear + 1); } else { $getYear = $getYear; } // if this year is divisable by 4 or 100, and is divisible by 400... then change last day of feb to 29. // if($getMonth == 2) { if (($getYear%4==0)||($getYear%100==0)) {$monthDays[1]=29;} if ($getYear%400==0) {$monthDays[1]=29;} } $firstDay = date(mktime(0,0,0,$getMonth,1,$getYear)); //Jan 1 2001 00:00:01 $firstDay = date('w', $firstDay);//0 through 6 (Sun - Sat) if($getMonth == 1) $buttonMonth = 'January'; if($getMonth == 2) $buttonMonth = 'February'; if($getMonth == 3) $buttonMonth = 'March'; if($getMonth == 4) $buttonMonth = 'April'; if($getMonth == 5) $buttonMonth = 'May'; if($getMonth == 6) $buttonMonth = 'June'; if($getMonth == 7) $buttonMonth = 'July'; if($getMonth == 8) $buttonMonth = 'August'; if($getMonth == 9) $buttonMonth = 'September'; if($getMonth == 10) $buttonMonth = 'October'; if($getMonth == 11) $buttonMonth = 'November'; if($getMonth == 12) $buttonMonth = 'December'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Shift Schedule</title> <link href="styleCalendar.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include_once("analyticstracking.php") ?> <table width="400px" align="center" border="0" cellpadding="1" cellspacing="0"> <tr> <td align="right"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear-1);?>" name="year"> <input type="submit" value="<<Year" name="submit" class="button-alt" /> </form> </td> <td align="left"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth-1);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear);?>" name="year"> <input type="submit" value="<<Month" name="submit" class="button-alt" /> </form> </td> <td align="center"><form method="POST" action="puller.php"><input type="submit" value=" Reset " name="submit" class="button-alt" /></form></td> <td align="right"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth+1);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear);?>" name="year"> <input type="submit" value="Month>>" name="submit" class="button-alt" /> </form> </td> <td align="left"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear+1);?>" name="year"> <input type="submit" value="Year>>" name="submit" class="button-alt" /> </form> </td> </tr> <tr> <td colspan="5" align="center"><H1><?PHP echo $buttonMonth;?> <?PHP echo $getYear;?></H1></td> </tr> </table> <?PHP echo '<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableOutterBorder">'; echo '<tr>'; for($i = 1; $i < 8; $i++) echo '<td width="120" align="center" class="weekDayHeaderCells">' . substr($dayName[$i], 0, 3) . '</td>'; echo '</tr>'; echo '<tr>'; $dayCount = 1; for ($ii = 0; $ii < $firstDay; $ii++) $dayCount = $dayCount + 1; if($ii >=1) echo '<td colspan="'.$ii.'" width="'.($ii*120).'" height="90" align="left" class="emptyCells"></td>';//Empty if($monthDays[1] == 29) $daysInMonth = 29; else $daysInMonth = $monthDays[$getMonth]; for ($i = 1; $i <= $daysInMonth; $i++) { $fDate = mktime(0,0,0,$getMonth,$i,$getYear);//Hr Mn Sec Mn Dy Yr $diffdate = round(($fDate - $startdate)/86400); $remainder = $diffdate%28; $showRow1 = $row1[$remainder]; $showRow2 = $row2[$remainder]; $showRow3 = $row3[$remainder]; //Highlight today if this month is selected if($getYear == $nowy && $i == $nowd && $buttonMonth == $nowm)$live = "Live"; if($showRow1 == $var1){ $class = "dayCellsE1" . $live; $weekSet = 1; $showJobs = '<br />Puller:'.$var1.'<br>Ground:'.$var2.'<br>Loco:'.$var3; }elseif($showRow1 == $var2){ $class = "dayCellsE2" . $live; $weekSet = 2; $showJobs = '<br />Puller:'.$var2.'<br>Ground:'.$var3.'<br>Loco:'.$var1; }else{ $class = "dayCellsE3" . $live; $weekSet = 3; $showJobs = '<br />Puller:'.$var3.'<br>Ground:'.$var1.'<br>Loco:'.$var2; } echo '<td width="120" height="90" valign="top" align="center" class="'.$class.'">'; echo '<span class="text_16_white">'.$i.'</span>'.$showJobs; echo '</td>'; $live = ''; if (($i+$firstDay)%7==0&&($dayCount<$daysInMonth+1)) echo '</tr><tr>'; } $totCells = $firstDay + $daysInMonth; for ($i = 0; $i < ($totCells > 28 ? ($totCells > 35 ? 42 : 35) : 28) - $totCells; $i++) echo ''; if($i >=1) echo '<td colspan="'.$i.'" width="'.($i*120).'" height="90" align="left" class="emptyCells"></td>';//Empty echo '</tr>'; echo '</table>'; ?> <br /> <center><a href="../" class="button-alt">ZENTYX</a></center> </body> </html> Any help is greatly appreciated.
  4. Ooops..I got to this post via my panel and forgot it started in javascript. Sorry for posting this PHP problem here. I removed the above post and added a new one to PHP
  5. Thanks for the info guys.Using javascript is not something I do often so I decided to convert it all to PHP. I appreciate you taking the time to help me. If anyone wants the code I will post it. Oh..if you want to see what I was going for look here...This is a 12hr shift schedule my workplace has. Now we cansee what we are working months/years in advance. Againthank you. Hooch
  6. Thanks Guy.But this gives me more errors. To show you how I implemented your code look below <script LANGUAGE="JavaScript"><!-- var dayName=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); var monthName=newArray("January","February","March","April","May","June","July","August","September","October","November","December"); var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31); var ondays=newArray("D","D","A","A","B","B","B","C","C","D","D","A","A","A","B","B","C","C","D","D","D","A","A","B","B","C","C","C"); var onnights=newArray("B","B","C","C","D","D","D","A","A","B","B","C","C","C","D","D","A","A","B","B","B","C","C","D","D","A","A","A"); var now=new Date(); var nowd=now.getDate(); var nowm=now.getMonth(); var nowy=now.getYear(); var startdate=new Date("Jan 1 2001 00:00:01"); function showCalendar(day,month,year) { // if this year is divisable by 4 or 100, and is divisible by 400... then change last day of feb to 29. // if ((year%4==0)||(year%100==0)) {monthDays[1]=29;} if (year%400==0) {monthDays[1]=29;} var firstDay=new Date(year,month,1).getDay() var calStr="<br><span id=instruction>Instruction<br></span id=instruction>" calStr+="<div class=headerRow>" calStr+="<span class=headerLeft><InPut type = button value = 'Last Month' onClick='nowm--; if (nowm<0) { nowy--;nowm=11; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerRight><InPut type = button value = 'Next Month'onClick='nowm++; if (nowm>11) { nowy++;nowm=0; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerCenter><font size=2>12 Hour Shift Schedule</font><br>"+monthName[month].toUpperCase()+","+year+"</span>" calStr+="</div class=headerRow><div class=headerDayRow>" for (var i=0;i<dayName.length;i++) calStr+="<span class=headerDays>"+dayName[i].substring(0,3)+"</span>" var dayCount=1 calStr+="</div class=headerDayRow><div class=dayRow>" for (var i=0;i<firstDay;i++) calStr+="<span class=emptyDaysTop> </span>" for (var i=0;i<monthDays[month];i++) {if (ondays == 'A' || ondays == 'C'){ calStr+="<span class=ACDays><span class=daynumber>"+dayCount++} else if (ondays == 'B' || ondays == 'D'){ calStr+="<span class=BDDays><span class=daynumber>"+dayCount++} var fDate = new Date(monthName[month]+" "+dayCount+" "+nowy+" 00:00:01") var diffdate = (fDate - startdate)/86400000 -1 var diffdate = Math.round(diffdate) var remainder=diffdate%28 var days=ondays[remainder] var nights=onnights[remainder] calStr+="</span><br><b>Days= " calStr+=days calStr+="<br>Nights= " calStr+=nights+"</b></span>" if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) calStr+="</div><div class=dayRow>" } var totCells=firstDay+monthDays[month] for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) calStr+="<span class=emptyDaysBottom> </span>" calStr+="</div>" //define what html to put in the span tag // calendar.innerHTML=calStr } //--></SCRIPT></head><body background="" bgcolor="#CCCCCC" text="#000000" link="#996600" vlink="#666666" alink="#336600"><center><SPAN ID=calendar><script> showCalendar(nowd,nowm,nowy)</SCRIPT></SPAN></center></body></html> This my show you what I am trying to do.Just an FYI this code (well the 1st code posted) only works in IE not FF Hooch
  7. Hi all.I came across a script that is exactly what I need, unfortunately it's mostly JS.I could work things out if it were PHP but I need some help here. Here is the code.. <html> <head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Shift Schedule</title> </head><body background="" bgcolor="#CCCCCC" text="#000000" link="#996600" vlink="#666666" alink="#336600"><script LANGUAGE="JavaScript"><!-- var dayName=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); var monthName=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31); var ondays=new Array("D","D","A","A","B","B","B","C","C","D","D","A","A","A","B","B","C","C","D","D","D","A","A","B","B","C","C","C"); var onnights=new Array("B","B","C","C","D","D","D","A","A","B","B","C","C","C","D","D","A","A","B","B","B","C","C","D","D","A","A","A"); var now=new Date(); var nowd=now.getDate(); var nowm=now.getMonth(); var nowy=now.getYear(); var startdate=new Date("Jan 1 2001 00:00:01"); function showCalendar(day,month,year) { // if this year is divisable by 4 or 100, and is divisible by 400... then change last day of feb to 29. // if ((year%4==0)||(year%100==0)) {monthDays[1]=29;} if (year%400==0) {monthDays[1]=29;} var firstDay=new Date(year,month,1).getDay() var calStr="<br><span id=instruction>Instruction<br></span id=instruction>" calStr+="<div class=headerRow>" calStr+="<span class=headerLeft><InPut type = button value = 'Last Month' onClick='nowm--; if (nowm<0) { nowy--; nowm=11; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerRight><InPut type = button value = 'Next Month'onClick='nowm++; if (nowm>11) { nowy++; nowm=0; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerCenter><font size=2>12 Hour Shift Schedule</font><br>"+monthName[month].toUpperCase()+", "+year+"</span>" calStr+="</div class=headerRow><div class=headerDayRow>" for (var i=0;i<dayName.length;i++) calStr+="<span class=headerDays>"+dayName[i].substring(0,3)+"</span>" var dayCount=1 calStr+="</div class=headerDayRow><div class=dayRow>" for (var i=0;i<firstDay;i++) calStr+="<span class=emptyDaysTop> </span>" for (var i=0;i<monthDays[month];i++) { calStr+="<span class=ACDays><span class=daynumber>"+dayCount++ var fDate = new Date(monthName[month]+" "+dayCount+" "+nowy+" 00:00:01") var diffdate = (fDate - startdate)/86400000 -1 var diffdate = Math.round(diffdate) var remainder=diffdate%28 var days=ondays[remainder] var nights=onnights[remainder] calStr+="</span><br><b>Days= " calStr+=days calStr+="<br>Nights= " calStr+=nights+"</b></span>" if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) calStr+="</div><div class=dayRow>" } var totCells=firstDay+monthDays[month] for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) calStr+="<span class=emptyDaysBottom> </span>" calStr+="</div>" //define what html to put in the span tag // calendar.innerHTML=calStr } //--></SCRIPT><center><SPAN ID=calendar><script> showCalendar(nowd,nowm,nowy)</SCRIPT></SPAN></center></body></html> Basically I need the following line calStr+="<span class=ACDays><span class=daynumber>"+dayCount++ to switch from it to this calStr+="<span class=BDDays><span class=daynumber>"+dayCount++ whenever the variable ondays is either A or C show the switch 1. When variable ondays is either B or D show switch 2. I tried many different ways with my knowledge of PHP but nothing works. Thank you for your time
  8. Gotcha! Thank you.
  9. Thanks reportingsjr, but I was wanting to trythis operation as is. It's a neat way to save some code. FYI if $a and $b do equal they will print out.. the query is equal1
  10. Hello all. I am trying out something new, and low and beholdI have a problem. The code below echo's out a "1" (without quotes)at the end of my text. <?PHP$a = "555";$b = "5555";$string = ($a == $b) ? include 'equal.php' : include 'not_equal.php';echo $string;?> equal.php <?PHPecho "the query is equal";?> not_equal.php <?PHPecho "the query is not equal";?> The above code prints out... the query is not equal1 Why is this? Thank youHooch
  11. ok great thanks man. Maybe I will add some text to the DB wheneverthis happens. It would be nice to know how many direct linksfrom the address bar are happening. More infois better. Well explained as usual, thank you Guy.
  12. Hello, I have yet another question. I am making a referrals page. It works almost to a tee. But whenI link to my page fom my browser it recordsnothing. The command for recording a referral from anactual web page is $url = $_SERVER['HTTP_REFERER']; Is there a similar "Predefined Variable" for a referralwhen one comes from the address bar? Right now I have a temporary fix that does nothingif $url = NULL. I was wondering if it's possible to record the userscomputer name?Thanks..Hooch
  13. Hooch

    using more sessions

    Here's how I ended up getting it to work.Thank you justsomeguy and vijay. <?phpsession_start();include 'includes/online.php';include 'includes/db.php';include 'includes/header.php';if (!($_SESSION['logged'] == 1)) { // #1 not logged inif (!$_POST['login']) { // #2 no post yet?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><link href="includes/style.css" rel="stylesheet" type="text/css" /></head><body><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="35"> </td> </tr></table><table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#999999"><form method="POST"> <tr> <td align=right> Username: <input name="username" type="text" class="txtbox" size="15" maxlength="25"></td> </tr> <tr> <td align="right"> Password: <input name="password" type="password" class="txtbox" size="15" maxlength="25"></td></tr><tr> <td align="center"> <input name="login" type="submit" class="txtbox" value="login"></td></tr> <tr> <td align="center"><a href="forgot_pass.php" target"_self" class="tia">Forgot Password</a><br> <a href="index.php" class="tour-footer">Home</a></td> </tr></form></table><?PHP } // #2 (end) just had a postif ($_POST['login']) { // #3 just had a postinclude 'includes/clean.php'; $username = clean($_POST['username']);$password = clean($_POST['password']);$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $r = mysql_fetch_array($query); $password2 = sha1($password);$password2 = sha1(substr($password2, 0, 20) . substr($r['salt'], 0, 20) . substr($password2, 19, 20) . substr($r['salt'], 19, 20)); if ($r['username'] == $username && $r['password'] == $password2){ // #4 check for username and pw $_SESSION['logged'] = 1; $_SESSION['username'] = $r['username']; $_SESSION['level'] = $r['level']; $_SESSION['accept'] = 0;} // #4 (end) check for username & pw is okelse{ // #5 username & pw is not ok $_SESSION['logged'] = 0; echo "<center><br><br><span class=\"black-medium\">Incorrect username or password!</span><br><br>"; echo "<a href=\"login.php\" target\"_self\" class=\"members\">Back</a><br><br><br>"; } // #5 (end) since username and pw are not ok, try again} // #3 (end) had a post and everything is ok} // #1 (end) user is logged inelse{session_write_close();}if ($_SESSION['logged'] == 1) {echo "<link href=\"includes/style.css\" rel=\"stylesheet\" type=\"text/css\" />";echo "<meta http-equiv=\"Refresh\" content=\"0; URL=profile.php\"/>";}else{}?></body></html>
  14. Hooch

    using more sessions

    The best spot I could find to put your code was in the same placethe old refresh was.It does not send me to profile.php. <?phpsession_start();include 'includes/online.php';include 'includes/db.php';include 'includes/header.php';if (!$_SESSION['logged'] == 1) { // #1 not logged inif (!$_POST['login']) { // #2 no post yet?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><link href="includes/style.css" rel="stylesheet" type="text/css" /></head><body><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="35"> </td> </tr></table><table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#999999"><form method="POST"> <tr> <td align=right> Username: <input name="username" type="text" class="txtbox" size="15" maxlength="25"></td> </tr> <tr> <td align="right"> Password: <input name="password" type="password" class="txtbox" size="15" maxlength="25"></td></tr><tr> <td align="center"> <input name="login" type="submit" class="txtbox" value="Login"></td></tr> <tr> <td align="center"><a href="forgot_pass.php" target"_self" class="tia">Forgot Password</a><br> <a href="index.php" class="tour-footer">Home</a></td> </tr></form></table><?PHP } // #2 (end) just had a postif ($_POST['login']) { // #3 just had a postinclude 'includes/clean.php'; $username = clean($_POST['username']);$password = clean($_POST['password']);$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $r = mysql_fetch_array($query); $password2 = sha1($password);$password2 = sha1(substr($password2, 0, 20) . substr($r['salt'], 0, 20) . substr($password2, 19, 20) . substr($r['salt'], 19, 20)); if ($r['username'] == $username && $r['password'] == $password2){ // #4 check for username and pw $_SESSION['logged'] = 1; $_SESSION['username'] = $r['username']; $_SESSION['level'] = $r['level']; $_SESSION['accept'] = 0;} // #4 (end) check for username & pw is okelse{ // #5 username & pw is not ok $_SESSION['logged'] = 0; echo "<center><br><br><span class=\"black-medium\">Incorrect username or password!</span><br><br>"; echo "<a href=\"login.php\" target\"_self\" class=\"members\">Back</a><br><br><br>"; } // #5 (end) since username and pw are not ok, try again} // #3 (end) had a post and everything is ok} // #1 (end) user is logged inelse{?><html><head><link href="includes/style.css" rel="stylesheet" type="text/css" /><meta http-equiv="Refresh" content="0;url=profile.php" /></head><body><a href="profile.php">Redirect</a></body></html><?PHP}?></body></html> The page source is as follows... </body></html> Why is that last "else" not working? Is my code completely messed up?Thank you very much for taking the time to look at my questionand helping me with another answer.Hooch
  15. Hooch

    using more sessions

    Hi vijay. it stays on the login.php If I remove the "Refresh" and just add some text to echo out, it does thesame thing. I'm thinking it's not that. I'll look at my code again later tonight. I was pretty tired wen I posted this. I was over it a few times. I triedchanging my script over and over...but this last posted part was whatI figured how it should be. Maybe a fresh look at it will give me some success. Thanks vijay.
  16. Hooch

    using more sessions

    I have decided to use sessions more. So of course I am having some problems. The following code (login.php) has a cpl problems. 1. once successfully logged in I am not redirected to the profile.php. - It's just a blank screen. 2. I will address this later. <?phpsession_start();include 'includes/online.php';include 'includes/config.php';include 'includes/header.php';if (!$_SESSION['logged'] == 1) { // #1 not logged inif (!$_POST['login']) { // #2 no post yet?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><link href="includes/style.css" rel="stylesheet" type="text/css" /></head><body><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="35"> </td> </tr></table><table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#999999"><form method="POST"> <tr> <td align=right> Username: <input name="username" type="text" class="txtbox" size="15" maxlength="25"></td> </tr> <tr> <td align="right"> Password: <input name="password" type="password" class="txtbox" size="15" maxlength="25"></td></tr><tr> <td align="center"> <input name="login" type="submit" class="txtbox" value="Login"></td></tr> <tr> <td align="center"><a href="forgot_pass.php" target"_self" class="tia">Forgot Password</a><br> <a href="index.php" class="tour-footer">Home</a></td> </tr></form></table><?PHP } // #2 (end) just had a postif ($_POST['login']) { // #3 just had a postinclude 'includes/clean.php'; $username = clean($_POST['username']);$password = clean($_POST['password']);$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $r = mysql_fetch_array($query); $password2 = sha1($password);$password2 = sha1(substr($password2, 0, 20) . substr($r['salt'], 0, 20) . substr($password2, 19, 20) . substr($r['salt'], 19, 20)); if ($r['username'] == $username && $r['password'] == $password2){ // #4 check for username and pw $_SESSION['logged'] = 1; $_SESSION['username'] = $r['username']; $_SESSION['level'] = $r['level']; $_SESSION['accept'] = 0;} // #4 (end) check for username & pw is okelse{ // #5 username & pw is not ok $_SESSION['logged'] = 0; echo "<center><br><br><span class=\"black-medium\">Incorrect username or password!</span><br><br>"; echo "<a href=\"login.php\" target\"_self\" class=\"members\">Back</a><br><br><br>"; } // #5 (end) since username and pw are not ok, try again} // #3 (end) had a post and everything is ok} // #1 (end) user is logged inelse{echo "<link href=\"includes/style.css\" rel=\"stylesheet\" type=\"text/css\" />";echo "<meta http-equiv=\"Refresh\" content=\"0; URL=profile.php\"/><center>redirect</center>";}?></body></html> Please let me know if my (if) statements are commented correctly.Wanting to learn more...Hooch
  17. Hooch

    md5 password

    I'm confused as to how the same password is getting hashed twice with the code I added. To my knowledge I am hashing 2 different password entries. I understand they couldbe the same password, but when "u_password" is hashed, I don't see how this ishashing "adb_password". Waiting to learn from the master....Hooch
  18. Ah, good to know. Thanks for taking the time.Hooch
  19. Hooch

    link trouble

    **Fixed!! Whew Changed $news = mysql_query("SELECT * FROM news WHERE `id` = '".$r['id']."' ") or die(mysql_error()); to $news = mysql_query("SELECT * FROM news WHERE `id` = '".$news."' ") or die(mysql_error());Hey all. I have successfully done this code a cpl times. But I am stumped why it's not working now. I have a page that shows many news articles. So I show only the first 100 characters then you linkto the news page to read more. $info = substr($r['info'], 0, 100) . "... <a href=\"news.php?news=".$r['id']."\" title=\"\" class=\"cep-bright-10\">[Read more]</a>"; This works because it shows the correct link and even goes to the right page. If I was linking to news article 3 this shows in the address bar "news.php?news=3" So far so good. Now the problem....no info gets outputted. Here's the short list of my code. <?PHP session_start(); include 'includes/config.php'; $news = mysql_query("SELECT * FROM news WHERE `id` = '".$r['id']."' ") or die(mysql_error()); $r = mysql_fetch_array($news); echo "<br><div class=\"cep-dark-bg-15\">".$r['header']."<br></div>"; echo "<div class=\"cep-dark-bg-10\">".$r['info']."<br><br></div>"; echo "<br>"; ?> hmmm???
  20. Hooch

    md5 password

    I suggest again to look how that is entered in the DB.Find the registration script and see how it's hashed.
  21. Hooch

    md5 password

    Show how you insert the 'member_login_key'to the database.Better make sure it's getting an MD5 correctly.
  22. Hooch

    md5 password

    I commented the lines that I edited.Hope it works...Hooch <?PHP# Simple password protection## (c) http://www.phpbuddy.com# Author: Ranjit Kumar# Feel free to use this script but keep this message intact!## To protect a page include this file in your PHP pages!session_start();//you can change the username and password by changing the above two stringsif (!isset($HTTP_SESSION_VARS['user'])) { if(isset($HTTP_POST_VARS['u_name'])) $u_name = $HTTP_POST_VARS['u_name']; if(isset($HTTP_POST_VARS['u_password'])) //*************************Changed line below*************************// $u_password = md5($HTTP_POST_VARS['u_password']); if(!isset($u_name)) { ?> <HTML> <HEAD> <TITLE><?php echo $HTTP_SERVER_VARS['HTTP_HOST']; ?> : Authentication Required</TITLE> </HEAD> <BODY bgcolor=#ffffff> <table border=0 cellspacing=0 cellpadding=0 width=100%> <TR><TD> <font face=verdana size=2><B>(Access Restricted to Authorized Personnel)</b> </font></td> </tr></table> <P></P> <font face=verdana size=2> <center> <?php $form_to = "http://$HTTP_SERVER_VARS[HTTP_HOST]$HTTP_SERVER_VARS[PHP_SELF]"; if(isset($HTTP_SERVER_VARS["QUERY_STRING"])) $form_to = $form_to ."?". $HTTP_SERVER_VARS["QUERY_STRING"]; ?> <form method=post action=<?php echo $form_to; ?>> <table border=0 width=350> <TR> <TD><font face=verdana size=2><B>User Name</B></font></TD> <TD><font face=verdana size=2><input type=text name=u_name size=20></font></TD></TR> <TR> <TD><font face=verdana size=2><B>Password</B></font></TD> <TD><font face=verdana size=2><input type=password name=u_password size=20></font></TD> </TR> </table> <input type=submit value=Login></form> </center> </font> </BODY> </HTML> <?php exit; } else { function login_error($host,$php_self) { echo "<HTML><HEAD> <TITLE>$host : Administration</TITLE> </HEAD><BODY bgcolor=#ffffff> <table border=0 cellspacing=0 cellpadding=0 width=100%> <TR><TD align=left> <font face=verdana size=2><B> You Need to log on to access this part of the site! </b> </font></td> </tr></table> <P></P> <font face=verdana size=2> <center>"; echo "Error: You are not authorized to access this part of the site! <B><a href=$php_self>Click here</a></b> to login again.<P> </center> </font> </BODY> </HTML>"; session_unregister("adb_password"); session_unregister("user"); exit; } $user_checked_passed = false; mysql_connect("localhost", "xxx", "xxx"); mysql_select_db("xxx"); if (isset($HTTP_SESSION_VARS['adb_password']) && isset($HTTP_SESSION_VARS['user'])) { //*************************Changed line below*************************// $adb_session_password = md5($HTTP_SESSION_VARS['adb_password']); $session_user = $HTTP_SESSION_VARS['user']; $result = mysql_query("SELECT member_login_key FROM ibf_members WHERE name='".mysql_real_escape_string($session_user)."'"); if ($row = mysql_fetch_assoc($result)) { if ($row['member_login_key'] == $adb_session_password) $admin = true; else $admin = false; } else $admin = false; if (!$admin) login_error($HTTP_SERVER_VARS['HTTP_HOST'],$HTTP_SERVER_VARS['PHP_SELF']); else { $user_checked_passed = true; } } if($user_checked_passed == false) { $result = mysql_query("SELECT member_login_key FROM ibf_members WHERE name='" . mysql_real_escape_string($u_name) . "'"); if ($row = mysql_fetch_assoc($result)) { if ($row['member_login_key'] == $u_password) $admin = true; else $admin = false; } else $admin = false; if (!$admin) login_error($HTTP_SERVER_VARS['HTTP_HOST'],$HTTP_SERVER_VARS['PHP_SELF']); session_register("adb_password"); session_register("user"); $adb_password = $u_password; $user = $u_name; $page_location = $HTTP_SERVER_VARS['PHP_SELF']; if(isset($HTTP_SERVER_VARS["QUERY_STRING"])) $page_location = $page_location ."?". $HTTP_SERVER_VARS["QUERY_STRING"]; header ("Location: ". $page_location); } }}?>
  23. Hooch

    md5 password

    I'm not sure how your code picks up the password, but here's something that may help. <?PHP$u_password = md5($_POST[u_password]); $info = mysql_query("SELECT * FROM users WHERE username = '$_POST[u_name]'") or die(mysql_error()); $row = mysql_fetch_array($info); if ($row['member_login_key'] == $u_password)?>
  24. As usual you are full of very useful knowledge.Thank you a whole bunch. There is a timestamp entry in the DB. $timestamp = time(); Notice my 1st post, second code box. The 4th entry is the $timestamp. Here it is again INSERT INTO `stats` VALUES ('ip goes here', '31-03-2007', 35, '1175397828', 'http://www.tiarts.org/index.php');INSERT INTO `stats` VALUES ('ip goes here', '31-03-2007', 1, '1175392978', 'http://www.tiarts.org/index.php');INSERT INTO `stats` VALUES ('ip goes here', '31-03-2007', 2, '1175395896', 'http://www.tiarts.org/index.php'); So the code you posted seems to be working correctly. // Jan 1 - July 31 $select1 = mysql_query("SELECT `online` FROM stats WHERE `online` BETWEEN " . mktime(0, 0, 0, 1, 1) . " AND " . mktime(0, 0, 0, 7, 31))or die(mysql_error()); $r = mysql_num_rows($select1); // Aug 1 - Oct 31 $select1 = mysql_query("SELECT `online` FROM stats WHERE `online` BETWEEN " . mktime(0, 0, 0, 8, 1) . " AND " . mktime(0, 0, 0, 10, 31))or die(mysql_error()); $r2 = mysql_num_rows($select2); // Nov 1 - Dec 31 $select1 = mysql_query("SELECT `online` FROM stats WHERE `online` BETWEEN " . mktime(0, 0, 0, 11, 1) . " AND " . mktime(0, 0, 0, 12, 31))or die(mysql_error()); $r3 = mysql_num_rows($select3); Now I want to start fresh every new year. So I added ",2007" after each day in the mktime function "mktime(0, 0, 0, 11, 1,2007) " This is working great. Now I want 2007 to be replaced by a variable. It needs to be the current year. So here is my final code. <?PHP // Entry of date to DB is "date( 'd-m-Y' )" $current = date('Y'); $r = 0; $select1 = 0; $r2 = 0; $select2 = 0; $r3 = 0; $select3 = 0; // Jan 1 - July 31 $select1 = mysql_query("SELECT `online` FROM stats WHERE `online` BETWEEN " . mktime(0, 0, 0, 1, 1, $current) . " AND " . mktime(0, 0, 0, 7, 31, $current))or die(mysql_error()); $r = mysql_num_rows($select1); // Aug 1 - Oct 31 $select2 = mysql_query("SELECT `online` FROM stats WHERE `online` BETWEEN " . mktime(0, 0, 0, 8, 1, $current) . " AND " . mktime(0, 0, 0, 10, 31, $current))or die(mysql_error()); $r2 = mysql_num_rows($select2); // Nov 1 - Dec 31 $select3 = mysql_query("SELECT `online` FROM stats WHERE `online` BETWEEN " . mktime(0, 0, 0, 11, 1, $current) . " AND " . mktime(0, 0, 0, 12, 31, $current))or die(mysql_error()); $r3 = mysql_num_rows($select3); ?> It seems to be working fine. But would you please have a look at the query and let me know if you would change anything?
×
×
  • Create New...