mysql - Why can't I use data after inserting to database with PHP -


problem: can't email value after inserting database.

edited:

fixed: problem $to = $_post['$email']; gave wrong value it. should $to = $_post['email'];. problem because had $ giving value.

this how create activation code:

$activation = sha1(uniqid(rand(), true)); 

this how declare database insert query:

$query = "insert users (activation, email) values (:activation, :email)";  

here populate parameters insert query:

$query_params = array(   ':activation' => $activation,   ':email' => $_post['email'] );  

...and here's how add data database executing query , send email:

    try      {          // execute query create user          $stmt = $db->prepare($query);          $stmt->execute($query_params);          if ($stmt->rowcount() > 0) { //if insert query_params successfull.             echo 'even gets  here.';               // send email:             $to = $_post['email'];             $subject = 'registeerimis kinnitus';             $from = 'from: mymail@gmail.com';             $website_url = "http://mysite.com";             $message = " kasutaja aktiveerimiseks, palun vajutage aadressile:\n\n";             $message .= $website_url . "/activate.php?email=" . urlencode($to) . "&key=".$activation;             mail($to, $subject, $message);         }     }      catch(pdoexception $ex)      {          // note: on production website, should not output $ex->getmessage().          // may provide attacker helpful information code.           die("failed run query: " . $ex->getmessage());      } 

the insert database works.

thanks in advance help.

try this

  $message .= $website_url . "/activate.php?email=" . urlencode($email) . "&key=".$activation; 

anyway use sha1(uniqid(mt_rand(), true));


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -