Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Marc Firth

@Marc Firth
About
Posts
508
Topics
14
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • login script returns blank page
    M Marc Firth

    This works (tested):

    <?php
    session_start();
    mysql_connect('localhost', 'user', 'pass');
    mysql_select_db('dbname');
    if (isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = sha1($_POST['password']);

    if (!empty($username) && !empty($password)) {
    	$query\_run = mysql\_query("SELECT id, password FROM users WHERE username = '$username' AND password = '$password' LIMIT 1");
    						
    	if (mysql\_num\_rows($query\_run) == 0) {
    		echo 'Invalid username / password combination';
    	} else {
    		echo 'Ok.';
    	}
    		
    } else {
    	echo 'You must supply a username and password.';
    }
    

    }
    ?>

    Username:
    " />

    Password:
    " />

    Portfolio | Surrey Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php html tools help

  • login script returns blank page
    M Marc Firth

    Try to output the hashed (sha1) password, and compare it to the one in the database. i.e. for user "joe" with password "bloggs" run the following code and compare the output to the mysql query below First get the hash you are creating when you log in (notice the "die"):

    <?php
    /**
    ** handles the login feature of the site
    ** check username and password with variables in the database
    */
    require_once("../includes/ikobe.php");

    if (isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];

    $pass = sha1($password);
    die($pass);
    
    if (!empty($username) && !empty($password)) {
        $query = "SELECT id FROM users WHERE username = '$username' AND password='$pass' LIMIT 1";
        $query\_run = mysql\_query($query);
        $query\_num\_row = mysql\_num\_rows($query\_run);
    
        if (mysql\_num\_rows($query\_run) == 0) {
            echo 'Invalid username / password combination';
        } else {
            echo 'Ok.';
        }
    
    } else {
        echo 'You must supply a username and password.';
    }
    

    }
    ?>

    Then compare it to the one in the database:

    The two results should match.

    Portfolio | Surrey Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php html tools help

  • login script returns blank page
    M Marc Firth

    That should work I think. - Removed quotes from 'id' - I added "LIMIT 1" to your query to only return a maximum of one result. You should also: - "Salt your passwords" - Clean Input using mysql_real_escape_string()

    Portfolio | Surrey Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php html tools help

  • how to copy
    M Marc Firth

    This should be what you need: http://phpsense.com/php/php-ftp-functions.html[^]

    Web Designer Portfolio | Surrey Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP com tutorial question

  • Extend PHPMyAdmin Token
    M Marc Firth

    multiply it by a billion?

    Portfolio | Surrey Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php mysql design hosting tutorial

  • why not submit
    M Marc Firth

    because you are trying to get a value from a submit button. to see what data has been sent from a form try this:

    <?php
    if (!empty($_POST)){
    foreach ($_POST as $key=>$value){
    $info .= $key.": ".$value."<br />";
    }
    echo $info;
    } else {
    echo "no data";
    }
    ?>

    Portfolio | Surrey Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php com beta-testing code-review

  • Minimizing the traffic
    M Marc Firth

    Same thing then really. It doesn't really matter which way the traffic is going - minimizing bandwidth means sending less content.

    Portfolio | Web Design, Web Hosting & IT Support

    Web Development php sysadmin help question

  • warning message
    M Marc Firth

    kamalesh5743 wrote:

    How to display warning message at html label using php script.

    Warning: blah blah blah

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP help php html tools tutorial

  • How to use postback in php
    M Marc Firth

    form.php:

    hello

    <?php
    if(isset($_POST['mydropdown'])) echo $_POST['mydropdown'];
    ?>

    or you can use ajax such as jquery's $.POST to do it without refreshing the page

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP tutorial csharp php asp-net

  • Find the differences betwween two arrays
    M Marc Firth

    Hi all, I have a problem finding the differences between two arrays:

    $first_array = array("a"=>"1", "b"=>"7", "c"=>"4", "d"=>"4");

    $second_array = array("a"=>"1", "b"=>"10", "c"=>"10", "d"=>"4", "e"=>"7");

    I'm trying to subtract the old array from the new one and find any new values. So the output should be:

    $new_array = array("b"=>"3", "c"=>"6", "e"=>"7");

    I tried using array_diff() and array_diff_assoc(). But they give me the wrong output. Any ideas? Thanks.

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php design hosting data-structures help

  • Minimizing the traffic
    M Marc Firth

    I presume you mean minimize the amount of bandwidth you are using. :doh: There are several things you can do: - Implement Caching. Give cached content as long a life as possible. - Implement Compression - Minify JavaScripts - If there are any images, optimise them. - Move as much content as possible onto alternate content hosts. - Use a tool such as the PageSpeed or ySlow plugins in FireFox to identify other bandwidth hogging areas. ... If you actually did mean "minimize the traffic", then just turn off the web server. :)

    Portfolio | Web Design, Web Hosting & IT Support

    Web Development php sysadmin help question

  • Silverlight deployment
    M Marc Firth

    Yeah, I've used that too. Nice to know about the SVN though. It's not something I've looked at in too much detail, but it's something I plan on looking at as my web team grows. Normal Backups are starting to get a bit silly...

    Portfolio | Web Design, Web Hosting & IT Support

    The Lounge com sysadmin tools question

  • Silverlight deployment
    M Marc Firth

    I had this problem when using flash. I got around it not by changing the file name but by adding a constantly changing variable on the end of the filename eg:

    myfile.swf?i=<?=unixtime();?>

    So you can keep the same filename and only code it once. I thought you might be able to do the same. Then again I've not used silverlight a lot so I'm not sure how it loads.

    Portfolio | Web Design, Web Hosting & IT Support

    The Lounge com sysadmin tools question

  • Interviewing / candidate qualifying tips
    M Marc Firth

    Posting in a rush so don't know if anyones mentioned it: Book There's some great questions & advice in there

    Portfolio | Web Design, Web Hosting & IT Support

    The Lounge csharp asp-net database sql-server winforms

  • JoomFish problem with my component
    M Marc Firth

    sharkbc wrote:

    Access denied for user 'ODBC'@'localhost' (using password: NO)

    Check your configuration file as it appears you can't connect to the database using your credentials. Your new install probably overwrote the config file.

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP database help php mysql com

  • Extend PHPMyAdmin Token
    M Marc Firth

    In case anyone's interested - add the following to our config.inc.php file:

    $cfg['LoginCookieValidity']=60 * 60 * 10;

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php mysql design hosting tutorial

  • How can I send e-mail with gmail account
    M Marc Firth

    using pear:

    <?php
    require_once "Mail.php";

    $from = "Sandra Sender ";
    $to = "Ramona Recipient ";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";

    // stick your GMAIL SMTP info here! ------------------------------
    $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("

    " . $mail->getMessage() . "

    ");
    } else {
    echo("

    Message successfully sent!

    ");
    }
    ?>

    from about.com

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP help question

  • How can I send e-mail with gmail account
    M Marc Firth

    you need to set: ini_set(sendmail_from, "youremail@gmail.com"); ini_set(SMTP, "smtpMailServerAddressGoesHere@gmail.com"); ini_set(smtp_port, 25); But I'm not sure what the correct values are.

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP help question

  • Extend PHPMyAdmin Token
    M Marc Firth

    Hi All, Anyone know how to extend the login token time in PHPMyAdmin? It's for my development machine (the default is way too short). I keep getting logged out after 1800 seconds. I know I've done it before, but I can't remember how. Thanks

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP php mysql design hosting tutorial

  • need a complete and free file manager
    M Marc Firth

    can you use FTP (e.g: FileZilla)?

    Portfolio | Web Design, Web Hosting & IT Support

    Linux, Apache, MySQL, PHP sysadmin linux question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups