Jump to content

DizzyThermal

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

DizzyThermal's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ahh, alright, not something I plan on changing once it's set.. I'll just embed it all in, Thanks Jocka
  2. Hey guys, I've set up a database with a login and logout script for my site.. There is a TINYINT value called admin and it either equals 1 or 0 depending on whether the user is an admin or not.. The registration script works perfectly to create the table value and the login script works fine for the site.. The question I had was if I wanted to add a link to the bottom of every page that said: Go to Administration Panel and make it only viewable by ADMINS I figured this little script would work.. Here would be the end of the page: <br /> <center>Copyright &copy 2010 <a href="http://www.website.com">www.WEBSITE.com</a></center> <?php include('includes/start_admincheck.php'); ?> <center><a href="<?php echo $homedir .'admin.php'; ?>">Go to Administration Panel</a></center> <?php include('includes/end_admincheck.php'); ?> </body> </html> Inside start_admincheck.php I have: (NOTE: $cUsername refers to a setcookie and $cAdmin does as well.. They are defined on my Variable page included at the top.) <?php include('variables/variables.php'); ?> <?php mysql_connect("$mysql_hostname", "$mysql_username", "$mysql_password") or die(mysql_error()); mysql_select_db("$mysql_database") or die(mysql_error()); if(isset($cUsername)) { $check = mysql_query("SELECT * FROM users WHERE username = '$cUsername'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if (($cAdmin == 1) && ($info['admin'] == 1)) { ?> And this is the end_admincheck.php <?php include('variables/variables.php'); ?> <?php } else die(); } } else die(); ?> ?> I get this Parse error thrown at the bottom of the page: Parse error: syntax error, unexpected $end in /*******/includes/start_admincheck.php on line 15 Naturally I would checkout line 15 in start_admincheck.php, but normally when I get an $end error it is the last line of the code and leaves me lost.. Something I'm missing guys? As always, thanks in advance
  3. Alright, If I put: <?php ob_start(); include("header.php"); ob_end_clean(); .... The redirect and cookie creation works fine, but the header file doesn't seem to be loading.. If I remove the ob_start(); and ob_end_clean(); and place exit(); after the two redirect headers: ..... header("Location: ".$hdir."files.php"); exit(); ..... It still doesn't work, same error Not really sure how the output buffering works
  4. Ahh, it's erroring about the setcookie's setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); What is this outputting to the browser that is bad? Am I not allowed to setcookie's on that user's computer?
  5. Errr.. After I posted this I saw the Sticky regarding Header posts.. I read the post and cannot find where the issue is with this.. [prays not to get flamed] :-\
  6. Hey guys, I've searched on Google for this and have had no luck, and you guys have been EXTREMELY helpful with a few of my previous questions! Alright the error I get is: Warning: Cannot modify header information - headers already sent by (output started at /****/header.php:6) in /***/*login.php on line 65 :-\ :-\ :-\ :-\ :-\ Errr.. After I posted this I saw the Sticky regarding Header posts.. I read the post and cannot find where the issue is with this.. The PHP code comes before the form information, am I missing something? :-\ :-\ :-\ :-\ :-\ My login.php script is: <?php include("header.php"); mysql_connect("10.6.186.84", "gilmdiniz", "Gil19471947") or die(mysql_error()); mysql_select_db("gilmdiniz") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else echo "SUP";//header($hdir."files.php"); } } if (isset($_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) die('<center>You did not fill in a required field! <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); if (!get_magic_quotes_gpc()) $_POST['email'] = addslashes($_POST['email']); $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) die('<center>This username does not exist in our database, sorry. <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); if ($_POST['pass'] != $info['password']) die('<center>Incorrect password, please try again. <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); else { $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); echo "SUP";//header($hdir."files.php"); } } } else { ?> <center> <a href="<?php echo $hdir .'index.php'; ?>"> Back to Home </a> <table border="1"> <tr><td> <center><h2>Login Information</h2></center> </td></tr> <tr><td> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <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> </td></tr> </table> </center> <?php } ?> and my header.php script is: <?php $hdir = "http://www.ondemandagents.com/NewSite_ALPHA/"; ?> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="<?php echo $hdir .'style.css'; ?>" /> </head> <body> <table width="920" cellspacing="0" cellpadding="10" border="0" align="center"> <tr> <td class="bodyline"> <table align="center" border="0" width="635" height="121" background="<?php echo $hdir .'images/logo.png'; ?>"> <tr> <td height="69"> <table border="0" width="635" height="106"> <tr> <td width="800" height="70"> </td> <td width="600" height="70"> </td> </tr> <tr> <td width="400" height="18"> </td> <td width="600" height="18"> <a href="<?php echo $hdir .'index.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_home.gif'; ?>" width="12" height="13" border="0" alt="Home" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Home </font></a> <a href="<?php echo $hdir .'files.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_files.gif'; ?>" width="12" height="13" border="0" alt="Files" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Files </font></a> <a href="<?php echo $hdir .'admin.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_login.gif'; ?>" width="12" height="13" border="0" alt="Administration" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Administration</font></a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> I have been using a header file in all my pages and scripts so far so that I wouldn't have to keep typing repetitive code.. Help is MUCH appreciated! Thanks in advance guys
  7. Awesome, thanks guys, is there an advantage to using one script over the other? Like speed wise? EDIT: Also, it's showing directories in the list.. This is kinda cool, but I can't distinguish between files and documents.. I believe unlink doesn't do documents right?
  8. At what point in the code is this unneeded?
  9. Hey guys, I've written a script that is suppose to Display the files within a specified directory /documents/ with check boxes to the right of them.. This worked out great. Then I wanted to devise a method to remove or unlink the selected files (via check box) when the user pressed a Submit button.. File Permissions on the server are 777 and I have hardcoded an unlink to test to see if it works and it does.. So the bug lies within my code.. Before I post the code let me explain my method in doing this. I created a for loop to name each check box after the corresponding file to the left and created a variable with the file name (to use later) Then on button press I made a for loop (it goes up to 50 because I wasn't sure how to make it the exact number of files and I didn't want to overload the server with say 1000000 :?) that goes through and checks the check box's values and if they equal 1, unlink the file in /documents/ Here's the code: <html> <body> <form action="" method="post" class="delete"> <?php $dir = "documents/"; if ($handle = opendir($dir)) { echo '<h2>List of Files in '.$dir.'</h2>'; echo '<table>'; for ($i = -2; false !== ($file = readdir($handle)); $i++) { if ($file != "." && $file != "..") { echo '<tr><td><a href="'.$dir.''.$file.'">'.$file.'</a></td><td><input type="checkbox" name="Del['.$i.']" /></td</tr>'; $DelFile[$i] = $file; } } echo '</table>'; closedir($handle); } ?> <br /> <input type="submit" name="submit" value="Delete Checked Files" /> </form> <?php for ($i = 0; $i <= 50; $i++) if ('Del['.$i.']' == 1) unlink("'.$dir.''.$DelFile[$i].'"); ?> </body> </html> Help is extremely appreciated, and Thanks in advance guys!
×
×
  • 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.