0

My registration script works on my local, but when i try it on my server, it doesn't do anything at all. You fill out the form and it returns the processing page empty. It doesnt re-direct after either.

$required = array("country","username","email","password","avatar","secretquestion","secretanswer");
            $error = false;

            foreach($required as $field){
                if(empty($_POST[$field])){
                    $error = true;
                }
            }

            if($error){
                echo '<p class="error_msg">An error occured. Make sure that all fields has been filled.</p>';
            } else {
                $country = $_POST['country'];
                $email = $_POST['email'];
                $user = $_POST['username'];
                $pass = $_POST['password'];
                $pass_hash = password_hash($pass, PASSWORD_DEFAULT);
                $avatar = $_POST['avatar'];
                $secquest = $_POST['secretquestion'];
                $secanswer = $_POST['secretanswer'];
                $date = date("Y-m-d");

                if($avatar == "alliance"){
                    $avatar = "/img/profiles/pref_alliance.png?195830";
                } elseif($avatar == "horde"){
                    $avatar = "/img/profiles/pref_horde.png?195831";
                }

                $existcheck = "SELECT username FROM users WHERE username=?";
                if($exists = $db->prepare($existcheck)){
                    $exists->bind_param("s", $user);
                    $exists->execute();
                    $result = $exists->get_result();
                    $num_rows = $result->num_rows;

                if($num_rows >= 1){
                    echo '<p class="error_msg">There is already an account that is registered with that name.</p>';
                } else {

                $sql = "INSERT INTO users(`country`,`email`,`username`,`password`,`u_avatar`,`is_gm`,`user_lvl`,`post_total`,`coins_total`,`vote_total`,`sec_quest`,`sec_answer`,`join_date`)
                VALUES(?,?,?,?,?,'0','member','0','0','0',?,?,?)";
                $stmt = $db->prepare($sql);
                $stmt->bind_param("ssssssss",$country,$email,$user,$pass_hash,$avatar,$secquest,$secanswer,$date);
                $stmt->execute();

                $stmt->close();
                $exists->close();
                $db->close();

                ///////////////////////////
                //////////EMAIL////////////
                ///////////////////////////

                $message = '<html><body style="font-family:verdana;">';
                $message .= '<table style="width:700px;background:#000;color:#FFF;"><tr><th><h2>Welcome to Shadowcrown!</h2></th></tr><tr><th>'.$_POST['username'].'</th></tr><tr><td><p>Thank you for joining the community. We are glad to have you in the community and we hope that you will enjoy your stay here aswell.<br><br>Join the battle in Azeroth. Play as your favorite faction and race and defeat anyone who stands in your way. Bring glory to your faction. Enjoy the feeling of playing the first expansion that was released for <strong>World of Warcraft</strong>.</p></td></tr> </table>';
                $message .= '</body></html>';

                    $subject = "Account Registration - Shadowcrown";
                    $headers = "From: support@shadow-crown.com\n";
                    $headers .= "Cc: support@shadow-crown.com\r\n";
                    $headers .= "X-Sender: support@shadow-crown.com\n";
                    $headers .= "X-Mailer: PHP/". phpversion();
                    $headers .= "X-Priority: 1\n";
                    $headers .= "Return-Path: support@shadow-crown.com\n";
                    $headers .= "MIME-Version: 1.0\r\n";
                    $headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
                    $to = $_POST['email'];

                    mail($to,$subject,$message,$headers);

                    header("Location: /register/register-success/");
                    exit();
                }
                }
            }
Synyster
  • 41
  • 5
  • What are the PHP versions on each? – Jonnix Oct 15 '16 at 17:49
  • You don't implement _any_ error detection or handling, you blindly trust that everything will work as expected. No wonder you then are puzzled if that is _not_ the case: you have no information. – arkascha Oct 15 '16 at 17:50
  • PHP version is 5.6 The reason i didnt input any error reporting is because im not 100% sure how reporting works for prepared statements. – Synyster Oct 15 '16 at 18:05
  • check out YCS' answers here and there. Like in the dupe target. If you set your connection up right, and have all your calls in a try/catch, you are good to go – Drew Oct 15 '16 at 18:34

0 Answers0