Jump to content

tang

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Everything posted by tang

  1. Consider using an include page if you aren't already. That way you can start your session, check that the member is logged in etc all in 1 file without having to re-type the same code in each file.
  2. include('check.php'); $query2 = "SELECT * from members WHERE mbr_name='$username'"; $result2 = mysql_query($query2) or die("The information you entered does not match our records."); $row2=mysql_fetch_array($result2); if ($_COOKIE["user"] == $row2['mbr_name']) { include('modules/console.php'); } Should be something like: include('check.php'); if (isset($_COOKIE["user"])) { $query2 = "SELECT * from members WHERE mbr_name='".mysql_real_escape_string($_COOKIE["user"])."'"; $result2 = mysql_query($query2) or die("The information you entered does not match our records."); $row2=mysql_fetch_array($result2); if (isset($_COOKIE["pass"]) && $_COOKIE["pass"] == $row['mbr_pass']) { include('modules/console.php'); } } EDIT: You also need to check that $rows were returned from your query, else the username was not found and the following code will fail.
  3. Reposting the code with highlighting and proper indentation will help :-D <?php require ('inc/config.php'); $linkid = @mysql_connect("$db_host", "$db_uname", "$db_pass"); mysql_select_db("$db_name", $linkid); include('check.php'); $query2 = "SELECT * from members WHERE mbr_name='$username'"; $result2 = mysql_query($query2) or die("The information you entered does not match our records."); $row2=mysql_fetch_array($result2); if ($_COOKIE["user"] == $row2['mbr_name']) { include('modules/console.php'); } else { if (isset($_GET['l'])) { if ($_GET['l'] == '1') { $username2=$_POST['username']; $password2=$_POST['password']; $query = "SELECT * from members WHERE mbr_name='$username2'"; $result = mysql_query($query) or die("The information you entered does not match our records."); $row=mysql_fetch_array($result); $dbpassword = $row['mbr_pass']; $userid = $row['id']; //$mdp=$row['password']; mysql_close($linkid); if ($dbpassword == md5($password2)) { //authenticate user $password5=md5($password2); //setcookie ("mdp", $mdp, $time); setcookie ("id", $userid); setcookie ("user", $username2); setcookie ("pass", $password5); //$username=$_COOKIE["user"]; include('modules/console.php'); //Header ("location: index2.php?p=status"); //test display authentication } else { echo "<center>Login Failed. <br><a href='index.php?p=cp'>Back</a></center>"; } } else { }?> <?PHP } else { ?> <form action="index.php?p=cp&l=1" method="post" enctype="application/x-www-form-urlencoded"><table width="400" border="0" align="center"> <tr> <td align="center" valign="top" class="style4">Login</td> </tr> <tr> <td align="left" valign="top"><table width="100%" border="0"> <tr> <td width="100" align="left" valign="top">Username</td> <td align="left" valign="top"><input name="username" type="text" size="15" maxlength="50" /></td> </tr> <tr> <td align="left" valign="top">Password</td> <td align="left" valign="top"><input name="password" type="password" size="15" maxlength="50" /></td> </tr> </table> </td> </tr> <tr> <td align="left" valign="top"> </td> </tr> <tr> <td align="left" valign="top"><input name="submit" type="submit" /></td> </tr> <tr> <td align="left" valign="top"> </td> </tr> </table></form> <?PHP } } ?>
  4. Just tested your original code and it works fine for me. Is that the very start of your headTemplate.php or is there anything preceeding it? EDIT: W00t ;-)
  5. I think you just divided by zero ;-) Should be: <?php include("includes/header.php"); include("includes/main_menu.php"); echo $content; include("includes/footer.php"); ?>
  6. Your original code should definitely work, can you show us headTemplate.php please?
  7. You can just use a standard input type=file field, when the form is posted the data should be available in the $_FILES array. You can then either move it to somewhere on your filesystem or read the contents with file_get_contents and insert it into the database. Post if you need more detail on any of those steps.
  8. $pagetitle should be being passed to 'templates/headTemplate.php' if that's what you mean? It won't be available anywhere else in your code though.
  9. I think that name is fine but I tend to use id= because it's valid for any element then (<p>, <div> etc). I think that name= might be links only but not 100%. So yep, name should be fine.
  10. Suggest that you use something like this: <a id="foo<?php echo $row['id_incr']; ?>" href="newbundle.php?action=edit&id=<?php echo $row['id_incr']; ?>">click here to process</a> Then you can just redirect to URL#foo<?php echo $row['id_incr']; ?> EDIT: To confirm, you shouldn't just use $row['id_incr'] as the link id as id's must not begin with a number to be valid xhtml. Doesn't have to be "foo" obviously, name it something short and relevant, just a single letter before the numbers is fine.
  11. Something like this: <?php session_start(); // Define your username and password $username = "Fileuser"; $password = "test98"; if (!isset($_SESSION['loggedIn'])) { $_SESSION['loggedIn'] = false; } if (isset($_POST['txtUsername']) && isset($_POST['txtPassword'])) { if ($_POST['txtUsername'] === $username && $_POST['txtPassword'] === $password) { $_SESSION['loggedIn'] = true; } } if ($_SESSION['loggedIn']) { // list your files } else { // display the login form ?> <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><label for="txtUsername">Username:</label> <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> <p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="Submit" value="Login" /></p> </form> <?php } // end display the login form
  12. I assume that you are echoing the value of $landingpage[1] later in your page, if so: $landingpage[1] = 'http://www.website.com/page1.php?value='.$id; If you do need to show the landingurl you've just assigned to the variable just do: echo $landingpage[1];
  13. You probably need some sort of data grid script. Search for php data grid or similar, find one, set it up and post if you have problems.
  14. echo your $query to the screen and post that. It should show what's going wrong.
  15. View the source of your page and compare it to the html that youtube advise that you use.
  16. I scoffed at that when I saw it, didn't think there would be much difference but I've done some tests and CURL is consistently faster over file_get_contents().
  17. No need for ActiveX, moodle does it with php: http://docs.moodle.org/en/NTLM_authentication Download an auth plugin from here: http://download.moodle.org/download.php/plugins/auth/ntlm.zip
  18. Don't use include, it has security implications. Either put it in an iframe (easy but probably not the "best" way to do it) or grab the contents with file_get_contents($url), parse it then include it in your page.
  19. Something like: SELECT `itemid` FROM `table` ORDER BY SUM(`quantity`) GROUP BY `itemid` Should do it. It's not very efficient though so will get slower the more items you have in your table. A better way would be to maintain a separate table with just itemid and quantity.
  20. I'm pretty sure you won't get youtube working through a web proxy. Could you install something like squid or privoxy on your server?
  21. I'm pretty sure it should be possible with some trickery if integrated auth is on but I don't know how you'd accomplish it. I think the code will be running as the windows user so it must be possible to look that up somewhere.... Anyone?
  22. You'll get more help if you offer more information. What is a supposed to do? What is b supposed to do? What isn't working? Any error messages? What are you trying to achieve?
  23. Keep your $fields array and do it that way. If you use tefuzz's code then anyone will be able to set any session variable on your system to whatever they like. EDIT: Your original code looks fine. Are you calling session_start();?
×
×
  • 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.