PHP help please

Discussion in 'Software' started by Bustergut, Apr 6, 2006.

  1. Bustergut

    Bustergut Private E-2

    I really shouldn't be allowed to play with such stuff, but can somebody advise what to do here. I downloaded a PHP/MYSQL FAQ system called FAQring. It appears to be what I want, but I fell at the first hurdle. I need to set the admin password by altering this script. Could you tell me how by pasting PASSWORDHERE into the following where I need to enter my password. I think it's near the values statement, but don't understand the syntax.

    <?ob_start();
    include("top.php");
    include("topinstallmenu.php");
    include "dataaccess1.php" ;
    session_start();
    if(session_is_registered("whossession")){
    if (($_SESSION['who'])=="admin"){
    if (!empty($_POST['password']))
    {
    $password =$_POST['password'];
    dbConnect();
    $result = mysql_query("delete from ".$tbladmin." where name='admin'" . mysql_error());
    if (!$result) {
    die('Invalid query: ' . mysql_error());
    }
    $result = mysql_query("insert into ".$tbladmin." (name,password) values('admin','" . $password . "')" . mysql_error());
    if (!$result) {
    die('Invalid query: ' . mysql_error());
    }
    header('location:admin.php');
    }
     
  2. goldfish

    goldfish Lt. Sushi.DC

    That takes an input from another page. There should be a page pointing to that script with a form with an input with name "password". The password isn't hardcoded into the script at all (and it would be a serious security hazard if it was).

    I've got to say that's some pretty ugly code. Even with indentation (which the board removes) it looks gnarley. Next time you post code snippets, please use the [ code ] tags.
     
  3. Bustergut

    Bustergut Private E-2

    Firstly, thanks for the reply. You've pointed me in the right direction and I've got it working now. The system appears to be simple to use, but badly implemented. For instance, when I type my password in for admin, it prints it in the box, so it appears to be a bit basic. I wish PHP writers documented their code for us simpletons and then I wouldn't have to post such stupid questions.

    Sorry for the badly posted code - didn't know about code tags.

    regards

    BG
     
  4. goldfish

    goldfish Lt. Sushi.DC

    Some PHP coders DO document their code, and they use these things called COMMENTS too. All of a sudden you know what the hell your code does! Just like magic. Unfortunately there are too many people out there that seem to think it's acceptable to hack away at their code and then release it on the unsuspecting public.

    There are a bunch of people who code nicely, particularly the people who develop WordPress.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds