0

我们如何在检查激活脚本.php 处将 email_activation db 中的所有详细信息添加到成员 db?移动 sql 数据库中的详细信息。

<?php
 require_once('recaptchalib.php');
 $privatekey = "your_private_key";
 $resp = recaptcha_check_answer ($privatekey,
 $_SERVER["REMOTE_ADDR"],
 $_POST["recaptcha_challenge_field"],
 $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
 // What happens when the CAPTCHA was entered incorrectly
 die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
 "(reCAPTCHA said: " . $resp->error . ")");
 } else {
 $username = $_POST['username'];
 $activation_code = $_POST['activation_code'];
 $db_host = "localhost";
 $db_name = "databasename";
 $db_use = "root";
 $db_pass = "password";
 $link = mysql_connect($db_host, $db_use, $db_pass);
 mysql_select_db($db_name, $link);
 $command = "UPDATE email_activation SET check_activation='$activation_code' WHERE username='$username' and activation='$activation_code'";
 $result = mysql_query($command);
 if ($result) {
 echo "Congratulations. Your membership has been activated …";
 }else{
 echo ("You've entered an invalid username / activation code – please retry");
 }
 }
 ?>
4

1 回答 1

0

使用INSERT INTO ... SELECT FROM

INSERT INTO member (username, fullname, email) 
  SELECT username, fullname, email FROM activation WHERE id = ?

但是为什么不立即将所有数据插入到带有激活未完成标志的成员表中呢?

于 2013-11-02T14:13:32.300 回答