Zainstalowałem sobie cms-a WordPress, utworzyłem nową podstrone.. w której chce umieścić rejestracje..
Poniższa rejestracja działa poprawnie, wyświetla dobry wynik bez naruszenia strony:)
<?php /*Config*/ 'db_host'=> '', //ip of db realm 'db_username' => '',//realm user 'db_password' => '',//realm password 'db_name'=> 'realmd',//realm db name ); ///////////////Start script////////////////// /* Function name: CHECK FOR SYMBOLS Description: return TRUE if matches. ( True = OK ) ( False = NOT OK) */ function check_for_symbols($string){ $alowed_chars="abcdefghijklmnopqrstuvwxyzAŚA¸AYABCDEFGHIJKLMNOPQRSTUVWXYZA†A~A…"; return FALSE; } /* Function name: OUTPUT USERNAME:PASSWORD AS SHA1 crypt Description: obious. */ function sha_password($user,$pass){ return SHA1($user.':'.$pass); } if ($_POST['registration']){ /*Connect and Select*/ if (!$realmd_bc_new_connect || !$selectdb){ die; } /*Checks*/ $username = $_POST['username']; $password = sha_password($username,$_POST['password']); if (check_for_symbols($_POST[password]) == TRUE || check_for_symbols($username) == TRUE || mysql_num_rows($qry_check_username) != 0){ echo "Error with creating account, might already be in use or your username / password has invalid symbols in it."; }else{ ('$username','$password')");// Insert into database. } }else{ ///////////////Stop script, Start HTML////////////////// ?> Username <input type="text" name="username"> Password <input type="password" name="password"> <input type="submit" name="registration"> </form> <?php // Do not remove this;) } ?>
Tylko ja bym chciał umieścić tą rejestracje:
<?php // Configuration. // Realm database. $r_db = "realmd"; // IP (and port). $ip = "127.0.0.1:3306"; // Username. $user = "trinity"; // Password. $pass = "trinity"; // Site title. $title = "Registration Form"; $title2 = "Some Server"; // End config. $page = '<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>' . $title . '</title> </head> <body style="background-color:black;color:yellow;font-family:verdana;"> <form method="post" action="' . $_SERVER["SCRIPT_NAME"] . '"> <p style="text-align:center;"> <strong>' . $title2 . ' - ' . $title . '</strong> <br /><br /><br /> Username: <br /><input name="username" type="text" maxlength="14" /><br /> Password: <br /><input name="password" type="password" maxlength="12" /><br /> Email: <br /><input name="email" type="text" maxlength="50" /> <br /><input name="tbc" type="checkbox" checked="checked" /> TBC<br /><br /><br /> <button type="submit">Submit</button> </p> </form> </body> </html>'; function error_s ($text) { echo("<br /><br /><a style=\"color:orange;\" href=\"" . $_SERVER["SCRIPT_NAME"] . "\">Go back...</a></p>"); }; $user_chars = "#[^a-zA-Z0-9_\-]#"; $email_chars = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/"; if (!$con) { }; error_s("You did not enter all the required information."); } else { error_s("Username too short."); }; error_s("Username too long."); }; error_s("Password too short."); }; error_s("Password too long."); }; error_s("Email was too short."); }; error_s("Email was too long."); }; error_s("Username contained illegal characters."); }; error_s("Password contained illegal characters."); }; error_s("Email was in an incorrect format."); }; if ($_POST['tbc'] != "on") { $tbc = "0"; } else { $tbc = "1"; }; $qry = @mysql_query("select username from " . mysql_real_escape_string($r_db) . ".account where username = '" . $username . "'", $con); if (!$qry) { }; foreach ($existing_username as $key => $value) { $existing_username = $value; }; }; error_s("That username is already taken."); }; $qry = @mysql_query("select email from " . mysql_real_escape_string($r_db) . ".account where email = '" . $email . "'", $con); if (!$qry) { }; foreach ($existing_email as $key => $value) { $existing_email = $value; }; }; if ($existing_email == $_POST['email']) { error_s("That email is already in use."); }; $register_sql = "insert into " . mysql_real_escape_string($r_db) . ".account (username, sha_pass_hash, email, expansion) values (upper('" . $username . "'),'" . $sha_pass_hash . "','" . $email . "','" . $tbc . "')"; if (!$qry) { }; }; } else { }; ?>
A w tym wypadku, strona rozsypuje się;/ po wyświetleniu wyniku... Jaka modyfikacja sprawiał by że strona poprawnie by działała.. pozdrawiam.