Jump to content

bettina702

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bettina702's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Fantastic. Its working now. Thanks so much Jack!!
  2. What I mean by column='1' is that I want the new password to overwrite the old one that is located in the one and only field in the database. Clearly thats not working. How do I get the new password to overwrite the old one?
  3. OK. I have it e-mailing now, but the code does not overwrite MySQL: mysql_query("UPDATE table SET column='$password' WHERE column='1'")
  4. Awesome, that worked!! Now the next part of the issue: Overwriting the previous password. I know the INSERT INTO thing is not how one does that. I tried using UPDATE this way: mysql_query("UPDATE table SET field WHERE field=1") or die('I cannot insert into the Database because: ' . mysql_error()); But it gives me this error message: I cannot insert into the Database because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE password=1' at line 1 Can you help me with that?
  5. Hi Jack, Can you tell me how I do that? Thanks!!
  6. Hi, I am a total newbie when it comes to PHP/MySQL. The project that I am working on requires me to generate a password, insert it and overwrite it in MySQL and then e-mail it out. For the most part it is working, I am e-mailing it and something is being inserted into MySQL, but the field is blank. Its as if the password generator isn't working or I am just missing something in my code. Please take a look. Any help is appreciated at this point! <?php $link = mysql_connect("a","b","c"); if (!$link) { die('I cannot connect to the database beacuse: ' . mysql_error()); } $db_selected = mysql_select_db("my_db" , $link); if (!$db_selected) { die("Can't connect: " . mysql_error()); } function generatePassword ($length = 5) { // start with a blank password $password = ""; // define possible characters $possible = "0123456789bcdfghjkmnpqrstvwxyz"; // set up a counter $i = 0; // add random characters to $password until $length is reached while ($i < $length) { // pick a random character from the possible ones $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); // we don't want this character if it's already in the password if (!strstr($password, $char)) { $password .= $char; $i++; } } // done! return $password; } mysql_query("INSERT INTO Table (field) VALUES('$password')") or die('I cannot insert into the Database because: ' . mysql_error()); $today = date("l, F j, Y"); $message = <<<ENDFORM Here is the new password for {$today}. Password = {$password}. Visit "http://www.domain.com" and log in. ... ENDFORM; $recipient1 = "Me <me@domain.com>"; $recipient2 = "Me <me@domain.com>"; $subject = "The Code for {$today}"; $headers .= "To: $recipent1"."\r\n"; $headers .= "From: $recipient2"."\r\n"; $headers .= "Bcc: $recipient2, $recipient1"."\r\n"; $headers .= "Reply-To: $recipient2"."\r\n"; $headers .= "X-Mailer: PHP-Mailer"; mail( "$recipient1, $recipient2", $subject, $message, $headers); mysql_close(); ?>
  7. Hi, I am building a website where part needs to be password protected. This password needs to be changed every 24 hours and e-mailed to several addresses. Can you help me or point me in the right direction? Any help is appreciated!
×
×
  • 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.