Simplytom Posted March 27, 2010 Share Posted March 27, 2010 Hello, I am trying to make a register forum, But ATM the mySQL queries don't work. Can anyone tell me what i am doing wrong? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link rel="stylesheet" type="text/css" href="../include/style.css" /> <?php include("../include/config.php"); ?> <title><?php echo $server_name ?> - Register</title> </head> <body> <?php include("../include/config.php"); $error = ''; $page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : ''; if ($page_mode == 'register') { $f_pass = $_POST['password']; $f_cpass = $_POST['c_password']; $f_acc = $_POST['accountname']; $f_email =trim($_POST['email']); $f_cemail =trim($_POST['c_email']); $f_flag = $_POST['flags']; if (!isValidEmail($f_email)) $error .='The Email address you have entered is not a valid email <br>'; if ($f_acc == '') $error .='Please Enter an accunt <br>'; if (strlen(trim($f_pass)) < 6) $error .='Password must be longer then 6 characters <br>'; if ($f_pass != $f_cpass) $error .='The two passwords do not match <br>'; if ($error == '') { mysql_connect ($database_host, $database_user, $database_pass); mysql_select_db ($db_logon); $results1 = mysql_query("SELECT id FROM account WHERE email='[$email]';"); if (mysql_num_rows(results1) > 0) $error .= "That email has already been used <br>"; else { $f_email_h = mysql_real_escape_string($f_email); $f_acc_h = mysql_real_escape_string($f_acc); mysql_query("INSERT into accounts (login, password, email, flags) VALUES ('{$f_acc_h}', '{f_pass}', '{f_email_h}', '{f_flag}')",$database_connect); header('location: thankyou.php'); } } } function isValidEmail($email = '') { return preg_match("/^[\d\w\/+!=#|$?%{^&}*`'~-][\d\w\/\.+!=#|$?%{^&}*`'~-]*@[A-Z0-9][A-Z0-9.-]{1,61}[A-Z0-9]\.[A-Z]{2,6}$/ix",$email); } ?> <?php include("../include/header.php"); ?> <div class="error_text"><?php echo $error; ?></div> <form action="register.php" method="post"> <input type="hidden" name="page_mode" value="register" /> <div class="left_box">Account Name:</div> <div class="right_box"><input name="accountname" type="text" maxlength="32" size="30"/></div> <div class="left_box">Password:</div> <div class="right_box"><input name="password" type="password" maxlength="32" size="30"/></div> <div class="left_box">Confirm Password:</div> <div class="right_box"><input name="c_password" type="password" maxlength="32" size="30"/></div> <div class="left_box">Email:</div> <div class="right_box"><input name="email" type="text" maxlength="32" size="30" /></div> <div class="left_box">Confirm Email:</div> <div class="right_box"><input name="c_email" type="text" maxlength="32" size="30"/></div> <div class="left_box">Wow Version</div> <div class="right_box"><select name="flags"> <option value="0">Classic WoW</option> <option value="8">The Burning Crusade</option> <option value="18">Wrath Of the Lich King (only)</option> <option value="24" selected="selected">WOTLK And TBC</option> </select></div> <div class="left_box"> </div> <div class="right_box"> <input name="Submit" type="submit" value="Create Account"/> <input name="Reset1" type="reset" value="Reset"/></div> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 27, 2010 Share Posted March 27, 2010 There's at least a dozen different things in the code you posted that could prevent the queries from being executed. Please narrow down the problem by describing the symptoms, errors, or result you are getting that leads you to believe that the queries don't work. Quote Link to comment Share on other sites More sharing options...
Simplytom Posted March 27, 2010 Author Share Posted March 27, 2010 There's at least a dozen different things in the code you posted that could prevent the queries from being executed. Please narrow down the problem by describing the symptoms, errors, or result you are getting that leads you to believe that the queries don't work. Well it doesn't work because i look into my database, and their is no new result added. their is also 1 record that i added manually through the database, and it doesn't stop me from creating a new user with the same account, Although it still doesn't insert into the database. Quote Link to comment Share on other sites More sharing options...
Amtran Posted March 27, 2010 Share Posted March 27, 2010 Okay, well, like PFMaBiSmAd said, there are QUITE a few errors in your code. Namely, VALUES ('{$f_acc_h}', '{f_pass}', '{f_email_h}', '{f_flag}') should be: VALUES ('{$f_acc_h}', '{$f_pass}', '{$f_email_h}', '{$f_flag}') header('location: thankyou.php'); should be: header('Location: thankyou.php'); and <?php echo $server_name ?> should be: <?php echo $_SERVER['SERVER_NAME']; ?> Those are the first three that I found, but I'm sure there are more. I can't believe that you didn't get any php errors. Try adding this to the top of your file: error_reporting(-1); and then see what comes up. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.