douao3063 2015-05-19 12:42
浏览 21

访客需要注册时注册错误

i have an error n my registration file, when i first write it there wa no errr but when a change it after a while for the social media section something happend, i deleted the whole registration and write it for a second time without the social media sections. But know i have the follow error and i can't see it.

Strict Standards: Only variables should be passed by reference in /home/joshua3/domains/recettes.nl/public_html/registreren.php on line 108

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' in /home/joshua3/domains/recettes.nl/public_html/registreren.php:140 Stack trace: #0 /home/joshua3/domains/recettes.nl/public_html/registreren.php(140): PDOStatement->execute() #1 {main} thrown in /home/joshua3/domains/recettes.nl/public_html/registreren.php on line 140

my code:

                                <?php
                            if($_SERVER['REQUEST_METHOD'] == 'POST') {
                                $errors = Array();

                                if(isset($_POST['name'])) {
                                    if(trim($_POST['name']) != '') {
                                        if(strlen(trim($_POST['name'])) < 2) {
                                            $errors[] = 'De voornaam is te kort (2).';
                                        }
                                    }else{
                                        $errors[] = 'De voornaam is leeg gelaten.';
                                    }
                                }else{
                                    $errors[] = 'Er is geen voornaam meegestuurd.';
                                }

                                if(isset($_POST['username'])) {
                                    if(trim($_POST['username']) != '') {
                                        if(strlen(trim($_POST['username'])) < 2) {
                                            $errors[] = 'De gebruikersnaam is te kort (2).';
                                        }
                                    }else{
                                        $errors[] = 'De gebruikersnaam is leeg gelaten.';
                                    }
                                }else{
                                    $errors[] = 'Er is geen gebruikersnaam meegestuurd.';
                                }

                                if(isset($_POST['lastname'])) {
                                    if(trim($_POST['lastname']) != '') {
                                        if(strlen(trim($_POST['lastname'])) < 2) {
                                            $errors[] = 'De achternaam is te kort (2).';
                                        }
                                    }else{
                                        $errors[] = 'De achternaam is leeg gelaten.';
                                    }
                                }else{
                                    $errors[] = 'Er is geen achternaam meegestuurd.';
                                }   

                                if(isset($_POST['genus'])) {
                                    if(trim($_POST['genus']) != '') {
                                        if(!in_array(trim($_POST['genus']), array_flip($config['general']['genus']))) {
                                            $errors[] = 'Dit geslacht bestaat niet!';
                                        }
                                    }else{
                                        $errors[] = 'Het geslacht is leeg gelaten.';
                                    }
                                }else{
                                    $errors[] = 'Er is geen geslacht meegestuurd.';
                                }                                   

                                if(isset($_POST['mail'])) {
                                    if(trim($_POST['mail']) != '') {
                                        if(filter_var(trim($_POST['mail']), FILTER_VALIDATE_EMAIL)) {
                                            $checkexist = $dbh->prepare('SELECT COUNT(id) FROM users WHERE mail = :mail');
                                            $checkexist->bindParam(':mail', trim($_POST['mail']), PDO::PARAM_STR);
                                            $checkexist->execute();
                                            if($checkexist->fetchColumn() > 0) {
                                                $errors[] = 'Er is al een account met dit mailadres.';
                                            }
                                        }else{
                                            $errors[] = 'De e-mail is ongeldig.';
                                        }
                                    }else{
                                        $errors[] = 'De e-mail is leeg gelaten.';
                                    }
                                }else{
                                    $errors[] = 'Er is geen e-mail meegestuurd.';
                                }

                                if(count($errors) == 0) {
                                    $name = trim($_POST['name']);
                                    $lastname = trim($_POST['lastname']);
                                    $genus = trim($_POST['genus']);
                                    $username = trim($_POST['username']);
                                    $email = trim($_POST['mail']);
                                    $password = generatepassword();
                                    $bcrypt = new Bcrypt($config['security']['passwordsafety']);
                                    $passwordHashed = $bcrypt->hash($password);
                                    $insert = $dbh->prepare('INSERT INTO users (id, username, password, mail, name, lastname, inserti, genus, lastonline) VALUES (NULL, :username, :password, :mail, :name, :lastname, :insterti, :genus, \'0000-00-00 00:00:00\')');
                                    $insert->bindParam(':username', $username, PDO::PARAM_STR);
                                    $insert->bindParam(':password', $passwordHashed, PDO::PARAM_STR);
                                    $insert->bindParam(':mail', $email, PDO::PARAM_STR);
                                    $insert->bindParam(':name', $name, PDO::PARAM_STR);
                                    $insert->bindParam(':lastname', $lastname, PDO::PARAM_STR);
                                    $insert->bindParam(':inserti', $inserti, PDO::PARAM_STR);
                                    $insert->bindParam(':genus', $genus, PDO::PARAM_STR);
                                    $insert->execute();
                                    $uid = $dbh->lastInsertId();
                                    $mail = new PHPMailer;
                                    /*$mail->isSMTP();                                      // Set mailer to use SMTP
                                    $mail->Host = $config['mail']['host'];  // Specify main and backup server
                                    $mail->SMTPAuth = true;                               // Enable SMTP authentication
                                    $mail->Username = $config['mail']['username'];                            // SMTP uscontrername
                                    $mail->Password = $config['mail']['password'];                           // SMTP password
                                    $mail->SMTPSecure = $config['mail']['secure'];                            // Enable encryption, 'ssl' also accepted*/
                                    $mail->From = $config['mail']['mail'];
                                    $mail->FromName = 'Recettes Noreply';
                                    $mail->addAddress($email, htmlentities(ucwords($name . ' ' . $lastname)));  // Add a recipient
                                    $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
                                    $mail->isHTML(true);                                  // Set email format to HTML
                                    $mail->Subject = 'Uw gegevens voor Recettes.nl';
                                    $mail->Body    = 'Er is succesvol een account geregistreerd in ons systeem,<br><li>Gebruikersnaam: ' . htmlentities($username) . '</i><br>Wachtwoord: <li>' . htmlentities($password) . '</li><br>U kunt <a href="http://www.recettes.nl/login" target="_blank">hier</a> inloggen.<br><br>Met vriendelijke groet,<br>Recettes team.';
                                    $mail->send();
                                    echo '<font color="green">Uw account is succesvol geregistreerd, er is een e-mail verstuurd met uw wachtwoord erin.</font><meta http-equiv="refresh" content="1;url=http://www.recettes.nl/login">';
                                    $added = true;
                                }else{
                                    echo alert('Er ging wat mis. De volgende dingen gingen fout:<ul><li>' . join('</li><li>', $errors) . '</li></ul>Uw account is helaas niet geregistreerd, probeer het opnieuw.', 'danger');
                                }
                            }
                            if(!isset($added)) {
                            ?>  

Please can someone solved the problem and exlaine what i do wrong in this code. Thnx a lot!

Oké new:

line 108 =

$checkexist->bindParam(':mail', trim($_POST['mail']), PDO::PARAM_STR);
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)