Jump to content

BMurtagh

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Posts posted by BMurtagh

  1. Hello,

     

    I'm working on a project at work in which I'm converting our old excel spreadsheets into an online php+mysql web-based system. I have the add user functionality and delete user functionality working, however I'm stuck with editing a current user's database information. I'm populating an "edit user" form with information from the DB based off of the user's ID#:

     

    $query = "SELECT * FROM Users WHERE UserID = '$id'";
    if (!$result) {
        echo "Could not successfully run query ($query) from DB: " . mysql_error();
        exit;
    }
    while($row = mysql_fetch_array($result)) {
    
    echo "<fieldset style=\"width:100\" align=\"center\"><legend><font color=\"#FFFF00\">Edit User Information</font></legend><br />";
    echo "<center><form id=\"edituser\" name=\"edituser\" method=\"post\" action="">";
    echo "<font color=\"#FFFF00\">Name:</font> <input type=\"text\" name=\"name\" id=\"name\" value=\"".$row['Name']."\">" . "<br /><br /><br />";
    echo "<font color=\"#FFFF00\">Username:</font> <input type=\"text\" name=\"username\" id=\"username\" value=\"".$row['Username']."\">" . "<br /><br />";
    echo "<font color=\"#FFFF00\">Password:</font> <input type=\"text\" name=\"password\" id=\"password\" value=\"".$row['Password']."\">" . "<br /><br /><br /><br />";
    echo "<font color=\"#FFFF00\">Department:</font> <input type=\"text\" name=\"dept\" id=\"dept\" value=\"".$row['Department']."\">" . "<br /><br />";
    echo "<font color=\"#FFFF00\">Location:</font> <input type=\"text\" name=\"loc\" id=\"loc\" value=\"".$row['Location']."\">" . "<br /><br /><br /><br />";
    echo "<font color=\"#FFFF00\">Printer 1:</font> <input type=\"text\" name=\"print1\" id=\"print1\" value=\"".$row['Printer1']."\">" . "<br /><br />";
    echo "<font color=\"#FFFF00\">Printer 2:</font> <input type=\"text\" name=\"print2\" id=\"print2\" value=\"".$row['Printer2']."\">" . "<br /><br />";
    echo "<br /><br /><br /></center>";
    }

     

    The main issue I'm currently running into is once the data is pulled from the DB into the textboxes, I go to click on say Name or any of the fields and it basically takes me back to the previous page (users.php) which is just a SELECT * FROM Users and displays the information in a table. On the users.php page, I have 2 post actions, one for edit & one for del:

     

    while($row = mysql_fetch_array($result)) 
    {
    $edit = "<form method=\"post\" action=\"edituser.php\"><input type=\"hidden\" name=\"UserID\" value=\"".$row['UserID'] ."\"><input type=\"image\" src=\"images/edit.png\" border=\"0\" alt=\"Edit Entry\"></form>";
    $delete = "<form method=\"post\" action=\"deluser.php\"><input type=\"hidden\" name=\"UserID\" value=\"".$row['UserID'] ."\"><input type=\"image\" src=\"images/del.png\" border=\"0\" alt=\"Edit Entry\"></form>";
    $id = $row['UserID'];
       	echo "<p><tr>";
       	echo "<td>" . $row['UserID'] . "</td>" .
        "<td> " . $row['Name'] . "</td>" .
    	"<td> " . $row['Username'] . "</td>" .
    	"<td> " . $row['Password'] . "</td>" . 
    	"<td> " . $row['Location'] . "</td>" .
    	"<td> " . $row['Department'] . "</td>" .
    	"<td> " . $row['Printer1'] . "</td>" . 
    	"<td> " . $row['Printer2'] . "</td>" . "</td>" . "<td align=\"center\">" .$edit . "</td><td align=\"center\">" . $delete . "</td>";
    echo "</tr>";
    }
    echo "</table></center><br /><br /><p>";

     

    I'm still confused/unsure why when after I populate the textboxes with the user's information I'm trying to edit it reverts back. If anyone has any suggestions, tips, or code snippets for a better way to do this, I'm interested. Thanks

  2. Hi Q,

     

    The 250 status messages of look to be successful ones according to the Microsoft (http://support.microsoft.com/?id=256321) documentation as well as looking up SMTP status codes. Have you attempted to add PHP's error reporting to your code to hopefully see if there's an underlying issue?

     

    ini_set("display_errors", "1");
    error_reporting(E_ALL);
    

     

    Another suggestion to confirm of the IIS SMTP service is working correctly would be to try using a simple ASP script that sends from the local SMTP to an address.

     

     

    As another side note, have you attempted to connect locally/remotely to the SMTP server using telnet? Hop on the server and type:

     

    telnet mail.domain.com(or IP of the SMTP server) 25

     

    This can be done locally or remotely and it should reply with a 220 status code meaning the service is ready.

  3. Hello,

     

    The way I'm reading your post is that you just want to keep pinging the IP address until you break the command. You should be able to just use ping <ip address> and it will keep going until you ctrl+c to interrupt it. If you only want it to ping a certain number of times then quit on its own, use the -c option, like this: ping -c 10 xxx.xxx.xxx.xxx

     

    Example 1:

    ping 74.125.127.100

      -- Will continuously send pings to the IP until you stop it.

     

    Example 2:

    ping -c 50 74.125.127.100

      -- Will send ping requests 50 times and then end.

     

    BTW, that IP was from google.com to be used as an example.

  4. Hi,

     

    You might have better luck providing the code you already have or are attempting to use. People aren't just going to reply back and say "here's the code" and do it for you. Only way to learn is by doing so give it a shot, do some research and piece some code together and test it out. See how things go from there and then if extra input is needed reply back here with the code & where things stand with the development.

  5. Hi there,

     

    The code I came up with (untested) when I took a look at it would be:

     

    userip = mysql_real_escape_string($ip);
    $sql ="SELECT * FROM tbl_ip WHERE ip='" . $userip . "')";
    $result = mysql_query($sql);
    
    if (!$result) {
        $message  = 'Invalid query: ' . mysql_error() . "\n";
        die($message);
      else {
       $is_bot = "TRUE";
    }

     

    Granted this is untested, but it should at least give you a beginning and allow others to comment changes or provide similar examples.

  6. Hi there,

     

    Remove <hr class="rule"/> line for each person listed and then two <br><br> tags and it'll remove the horizontal line and keep some decent, readable spacing. I also suggest getting Firebug for Firefox that allows you to do a lot of HTML and web development interaction on pages you browse to. See http://getfirebug.com/

  7. Hi AM,

     

    Put up a simple PHP info page in a web accessible directory and have the following code to output a run down of PHP on your system:

     

    <?php phpinfo(); ?>

     

     

     

     

  8. Hey,

     

    J.Daniels is on the right track. Use the following line:

     

    chmod -R 777 /thumbs

     

    However, as mentioned before the 777 full permission is quite drastic and would consider lowering those permissions to a more ideal level.

  9. Hi,

     

    I'm a bit confused, why would you want to change the root user's home directory? /root is a standard  directory in the root directory (as are /bin, /boot, /dev, /etc, /home, /mnt, /sbin and /usr). The root directory is the top level directory on any Unix-like operating system, i.e., the directory that contains all other directories and their subdirectories. /root contains configuration files for the root account, just as each ordinary user's home directory (which is by default a subdirectory of the /home directory) contains configuration and other files for that user. Please provide some more insight so we can help you out

  10. Hey there,

     

    You'll wanna take a look at the PHP strstr() function for this. I'm including a little code example to get you going, but the best resource for learning about the function is at:

    http://www.php.net/manual/en/function.strstr.php

     

    <?php
    // get last directory in $PATH
    $text = "dude wheres my car user";
    $test = "kick user dsdf3243221sad";
    
    // get everything after last newline
    
    if (strstr($test, "kick user"))
            echo "true";
       else
            echo "false";
    ?>

  11. Hey scunt,

     

    First thing I would do is to view the error_log of your website after you make the site error out. You can also tail the error_log while you do this to give you real-time display. You may need to contact your host to get access to the error_log or be granted SSH access.

     

    Make sure in your php.ini file that the following two entries in php.ini are set:

     

    error_reporting = E_ALL

    log_errors = On

     

    If you have access to the logs via SSH you can do: tail -n0 -f <path/to/your/error_log.log> which will keep the error_log open until you ctrl+c it, but should show you the PHP error that is occurring. If you only have FTP access to the logs after the fact, you would need to replicate the issue, download the logs, and then check the timestamp for the correct error.

  12. Hi,

     

    You can also specify in your PHP code (if PEAR support is enabled) the SMTP host, username, and password to send authenticated email. Below is just an alternate to explicitly set the SMTP server in your code instead of making changes to sendmail.

     

    <?php
    require_once "Mail.php";
    
    $from = "Sandra Sender <sender@example.com>";
    $to = "Ramona Recipient <recipient@example.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    
    $host = "mail.example.com";
    $username = "smtp_username";
    $password = "smtp_password";
    
    $headers = array ('From' => $from,
      'To' => $to,
      'Subject' => $subject);
    $smtp = Mail::factory('smtp',
      array ('host' => $host,
        'auth' => true,
        'username' => $username,
        'password' => $password));
    
    $mail = $smtp->send($to, $headers, $body);
    
    if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
    } else {
      echo("<p>Message successfully sent!</p>");
    }
    ?>

  13. Hi Nate,

     

    One method that I think would be more benefitial for you would be to use a .htaccess file and restrict access that way. This would rule out the possibility of someone forging the address from the web page if their IP wasn't in the allowed range.

     

    An .htaccess example would be:

     

    # IP entries in .htaccess file

    Deny from all

    Allow from 192.168

    Allow from 64.233.187.99

    # end of .htaccess

     

    The subsequent Allow from and Deny from arguments may be

     

        * A full IP adress, like 10.1.2.3

        * A partial IP adress, like 10.1 (head part of IP)

        * network/netmask or CIDR (see apache documentation)

     

    Following example will restrict everybody from accessing the pages, except users with IP beginning with 192.168 (local network) and for some user from the Internet with ip adress "64.233.187.99". Since the IPs are going to be static, you shouldn't need to worry about the code since you'll only be accepting access from the trusted IPs/IP range you choose.

     

     

     

     

  14. Do you have to use two databases? Both ASP.NET and PHP have MSSQL and MySQL support which allows you to connect to one database with all of the information from either application. This would save on administering two databases and probably would make your life a bit easier too. If you're thinking about doing it this way I would go with the MSSQL database and then use PHP's support to connect to it. Below is a list of the DB functions:

     

    http://php.net/manual/en/book.mssql.php

  15. Rob,

     

    You're going to want to check out the Apache error logs to see if the error messages in more detail are being written. If logging isn't enabled, I would do so and then when Apache acts up again you can check. Checking the error logs is usually a good starting place to get some preliminary info as to what is possibly occurring.

     

    To find the location of the error logs for Apache check in the httpd.conf file for the ErrorLog directive. http://httpd.apache.org/docs/1.3/logs.html also gives you additional info too.

×
×
  • 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.