Autor | Zpráva | ||
---|---|---|---|
Dvora21 Profil * |
#1 · Zasláno: 17. 12. 2008, 12:35:58
Dobry den, mám problém takovi na můj web mam registraci a nevim jak tammam pridat este ICQ, jabber, www, EMAIL, vsecko do mysql a ikonku ktera nepujde do mysql ale do ftp zde to mam:
<? session_start(); include("database.php"); /** * Returns true if the username has been taken * by another user, false otherwise. */ function usernameTaken($username){ global $conn; if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "select username from users where username = '$username'"; $result = mysql_query($q,$conn); return (mysql_numrows($result) > 0); } /** * Inserts the given (username, password) pair * into the database. Returns true on success, * false otherwise. */ function addNewUser($username, $password){ global $conn; $q = "INSERT INTO users VALUES ('$username', '$password')"; return mysql_query($q,$conn); } /** * Displays the appropriate message to the user * after the registration attempt. It displays a * success or failure status depending on a * session variable set during registration. */ function displayStatus(){ $uname = $_SESSION['reguname']; if($_SESSION['regresult']){ ?> <h1>Registrace proběhla ůspěsně!</h1> <p>Vítej <b><? echo $uname; ?></b>, teď se můžeš <a href="main.php" title="Login">přihlásit</a>.</p> <? } else{ ?> <h1>Chyba Registrace!</h1> <p>Registrace <b><? echo $uname; ?></b> proběhla neuspěšně...<br> Prosím skuste to později.</p> <? } unset($_SESSION['reguname']); unset($_SESSION['registered']); unset($_SESSION['regresult']); } if(isset($_SESSION['registered'])){ /** * This is the page that will be displayed after the * registration has been attempted. */ ?> <html> <title>Registrace</title> <body> <? displayStatus(); ?> </body> </html> <? return; } /** * Determines whether or not to show to sign-up form * based on whether the form has been submitted, if it * has, check the database for consistency and create * the new account. */ if(isset($_POST['subjoin'])){ /* Make sure all fields were entered */ if(!$_POST['user'] || !$_POST['pass']){ die('You didn\'t fill in a required field.'); } /* Spruce up username, check length */ $_POST['user'] = trim($_POST['user']); if(strlen($_POST['user']) > 30){ die("Sorry, the username is longer than 30 characters, please shorten it."); } /* Check if username is already in use */ if(usernameTaken($_POST['user'])){ $use = $_POST['user']; die("Sorry, the username: <strong>$use</strong> is already taken, please pick another one."); } if(!$_POST['email']){ die('You didn\'t fill in the email field, silly'); } /* Add the new account to the database */ $md5pass = md5($_POST['pass']); $_SESSION['reguname'] = $_POST['user']; $_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass); $_SESSION['registered'] = true; echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[PHP_SELF]\">"; return; } else{ /** * This is the page with the sign-up form, the names * of the input fields are important and should not * be changed. */ ?> <html> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <title>Registrace</title> <body bgcolor="#55AACC"> <h1>Register</h1> <form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>E-mail:</td><td><input type="text" name="email" maxlength="50"></td></tr> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr> <tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Join!"></td></tr> </table> </form> </body> </html> <? } ?> a este tabulka do mysql: CREATE TABLE IF NOT EXISTS `users` ( `username` varchar(30) collate latin2_czech_cs default NULL, `password` varchar(32) collate latin2_czech_cs default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin2 COLLATE=latin2_czech_cs; |
||
radas Profil * |
#2 · Zasláno: 17. 12. 2008, 13:54:46
přidej si do tabulky požadované sloupce a tak samo do formulaře dej ty samé vstupní pole
|
||
Dvora21 Profil * |
#3 · Zasláno: 17. 12. 2008, 16:00:09
jo a do php aby se to dalo do mysql to prave me to hrazi errory
|
||
ixiik Profil |
#4 · Zasláno: 17. 12. 2008, 16:04:54
Jednoduchá logika
- Vytvoř si v DB v tabulce nová pole pro hodnoty které tam chceš vkladat. - Uprav si html kód abys tam měl žádaná pole - Uprav si PHP kód, aby ty nová pole z formuláře přečetl - Uprav si PHP kód aby ty nové hodnoty zapsal do DB |
||
Dvora21 Profil * |
#5 · Zasláno: 17. 12. 2008, 16:22:30
to chapu :D ALE ESTE TO musim udelat :D uz se do toho poustím
|
||
Dvora21 Profil * |
#6 · Zasláno: 18. 12. 2008, 13:54:50
Prosím vás, mmě to nejde nemohl by ste mi udelat provizorní jedno treba Email: aby se to odeslalo do mysql prosím... ja už bych to z toho emailu okopiroval na ostatni. dekuji.
|
||
Časová prodleva: 15 let
|
0