chatmaster Posted March 10, 2009 Share Posted March 10, 2009 Hi all just call me mister noob. Im creating a registration page and trying to check if a username is already taken and if it is a message to appear to say that its taken but even when ive not typed anything it still says Username is already taken please choose another. Could you look at my code and tell me what im doing wrong please. The code im talking about is inbetween the forward slashes <?php include('mydbfile'); $conn = mysql_connect("$hostname_dbconnect","$username_dbconnect","$password_dbconnect") or die ("cannot connect"); $dbconn = mysql_select_db("$database_dbconnect",$conn) or die ("cannot select DB"); if (isset($_POST['submit'])) { } else { $username = ""; $password = ""; $confpass = ""; $city = ""; $gender = ""; $lookingfor = ""; $email = ""; $emailconf = ""; $dobd = ""; $dobm = ""; $doby = ""; } ///////////////////////////////////////////////////////////////////////////////////////// $searchQuery = "SELECT username FROM users WHERE username = '$username' LIMIT 1"; $queryFinding = mysql_query($searchQuery); if(mysql_num_rows($queryFinding) == 1) { $message = "Username is already taken please choose another."; } //$queryResult = mysql_num_rows($queryFinding); /////////////////////////////////////////////////////////////////////////////////////// //All the information to be passed to the database. $username = mysql_real_escape_string($_POST['Username']); $password = mysql_real_escape_string($_POST['Password']); $confpass = mysql_real_escape_string($_POST['Confirm password']); $city = mysql_real_escape_string($_POST['City']); $gender = mysql_real_escape_string($_POST['Gender']); $lookingfor = mysql_real_escape_string($_POST['Looking_for']); $email = mysql_real_escape_string($_POST['email']); $emailconf = mysql_real_escape_string($_POST['Confirm E-Mail']); $dobd = mysql_real_escape_string($_POST['dobd']); $dobm = mysql_real_escape_string($_POST['dobm']); $doby = mysql_real_escape_string($_POST['datey']); $dobtotal = $doby.'-'.$dobm.'-'.$dobd; $dateofbirth = mysql_real_escape_string($_POST['$dobtotal']); $sql = "INSERT INTO users (id, username, password, city, gender, looking_for, date_of_birth, email) VALUES ('', '$username',SHA1('$password'),'$city','$gender','$lookingfor', '$dobtotal','$email')"; $DBCON = mysql_query($sql, $conn); // ?> <!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" xml:lang="en" lang="en"> <head> <title>Chatlol: Coming soon</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="layout.css" rel="stylesheet" type="text/css" /> </head> <body id="page2"> <div id="main"> <!-- header --> <div id="header"> <div class="row_1"> <ul class="menu"> <li><a href="index.php">main page</a></li> <li><a class="current" href="register.php">register</a> <ul> <li><a href="forgotpass.php">forgot pass</a></li> </ul> </li> <li><a href="online.php">members online</a></li> <li><a href="tos.php">terms of service</a></li> <li><a href="faqs.php">faqs</a></li> <li><a class="last" href="mailto:[email protected]">contact me</a></li> </ul> </div> <div class="row_2"> <a href="index.html"><img alt="" src="images/logo.jpg" /></a> </div> </div> <!-- content --> <div id="content"> <div class="col_1"> <div class="box1 p1"> <div class="inner"> <h3>Events calendar</h3> <div class="inner1"></div> </div> </div> <div class="box2"> <div class="inner"> <h3 class="marker5">special news</h3> <div class="inner1"> <h4><?php echo date('d/m/Y'); ?></h4> Chatlol will up and running soon. <div class="block"> <div class="ind"> <h5><a href="#">Aenean nonumysiceres</a></h5> <img alt="" src="images/2page_pic1.jpg" /> </div> </div> <h4><?php echo date('d/m/Y'); ?></h4> The new and upcoming chat site will be here soon.</div> </div> </div> </div> <div class="col_2 indent"> <div class="row_1"> <p> </p> <p><br /> </p> <form method="POST" enctype="multipart/form-data" name="register" id="register"> <table width="290" border="1" class="box3"> <tr> <td width="80"><div align="right"> <label>Username</label> </div></td> <td width="194"><div align="left"> <input name="Username" type="text" id="Username" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><div align="right"> <label>Password</label> </div></td> <td><div align="left"> <input name="Password" type="password" id="Password" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><label> <div align="right">Confirm password</div> </label></td> <td><div align="left"> <input name="Confirm password" type="password" id="Confirm password" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><div align="right"> <label>City</label> </div></td> <td><div align="left"> <input name="City" type="text" id="City" size="33" maxlength="60" /> </div></td> </tr> <tr> <td><div align="right"> <label>Gender</label> </div></td> <td><div align="left"> <select name="Gender" id="Gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> </div></td> </tr> <tr> <td><div align="right"> <div align="right"> <label>Looking for</label> </div> </div></td> <td><div align="left"> <select name="Looking_for" id="Looking_for"> <option value="Friendship">Friendship</option> <option value="Email and Chat">Email and Chat</option> <option value="Relationship">Relationship</option> <option value="Fun">Fun</option> <option value="No strings fun">No strings fun</option> <option value="Other">Other</option> </select> </div></td> </tr> <tr> <td><div align="right"> <label>E-Mail</label> </div></td> <td><div align="left"> <input name="email" type="text" id="email" size="33" maxlength="50" /> </div></td> </tr> <tr> <td><div align="right"> <label>Confirm E-Mail</label> </div></td> <td><div align="left"> <input name="Confirm E-Mail" type="text" id="Confirm E-Mail" size="33" maxlength="50" /> </div></td> </tr> <tr> <td><label> <div align="right">Date of birth</div> </label></td> <td><label> <select name="dobd" id="dobd"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="dobm" id="dobm"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="datey" id="datey"> <option value="1934">1934</option> <option value="1935">1935</option> <option value="1936">1936</option> <option value="1937">1937</option> <option value="1938">1938</option> <option value="1939">1939</option> <option value="1940">1940</option> <option value="1941">1941</option> <option value="1942">1942</option> <option value="1943">1943</option> <option value="1944">1944</option> <option value="1945">1945</option> <option value="1946">1946</option> <option value="1947">1947</option> <option value="1948">1948</option> <option value="1949">1949</option> <option value="1950">1950</option> <option value="1951">1951</option> <option value="1952">1952</option> <option value="1953">1953</option> <option value="1954">1954</option> <option value="1955">1955</option> <option value="1956">1956</option> <option value="1957">1957</option> <option value="1958">1958</option> <option value="1959">1959</option> <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> <option value="1964">1964</option> <option value="1965">1965</option> <option value="1966">1966</option> <option value="1967">1967</option> <option value="1968">1968</option> <option value="1969">1969</option> <option value="1970">1970</option> <option value="1971">1971</option> <option value="1972">1972</option> <option value="1973">1973</option> <option value="1974">1974</option> <option value="1975">1975</option> <option value="1976">1976</option> <option value="1977">1977</option> <option value="1978">1978</option> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> </select> </label></td> </tr> </table> <p> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> </p> <p>/////////////////////////<?php echo $message ?> </p>//////////////// </form> <h4> </h4> </div> <div class="container row_2"> <div class="column1"></div> <div class="clear"></div> </div> </div> <div class="clear"></div> </div> <!-- footer --> <div id="footer"> <ul class="footer_menu"> <li><a href="#">main page</a></li> <li><a href="#">city</a></li> <li><a href="#">help</a></li> <li><a href="#">events</a></li> <li><a href="#">map</a></li> <li><a href="#">tourism</a></li> <li><a class="last" href="#">Contacts</a></li> </ul> <p>City portal © 2008. <a href="#">Privacy Policy</a></p> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/ Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Please use code tags when posting code ( it is the # symbol). Also try this: <?php include('mydbfile'); $conn = mysql_connect("$hostname_dbconnect","$username_dbconnect","$password_dbconnect") or die ("cannot connect"); $dbconn = mysql_select_db("$database_dbconnect",$conn) or die ("cannot select DB"); if (isset($_POST['submit'])) { } else { $username = ""; $password = ""; $confpass = ""; $city = ""; $gender = ""; $lookingfor = ""; $email = ""; $emailconf = ""; $dobd = ""; $dobm = ""; $doby = ""; } ///////////////////////////////////////////////////////////////////////////////////////// $searchQuery = "SELECT username FROM users WHERE username = '$username' LIMIT 1"; $queryFinding = mysql_query($searchQuery); $count = mysql_num_rows($queryFinding); if($count > 0) { $message = "Username is already taken please choose another."; } //$queryResult = mysql_num_rows($queryFinding); /////////////////////////////////////////////////////////////////////////////////////// //All the information to be passed to the database. $username = mysql_real_escape_string($_POST['Username']); $password = mysql_real_escape_string($_POST['Password']); $confpass = mysql_real_escape_string($_POST['Confirm password']); $city = mysql_real_escape_string($_POST['City']); $gender = mysql_real_escape_string($_POST['Gender']); $lookingfor = mysql_real_escape_string($_POST['Looking_for']); $email = mysql_real_escape_string($_POST['email']); $emailconf = mysql_real_escape_string($_POST['Confirm E-Mail']); $dobd = mysql_real_escape_string($_POST['dobd']); $dobm = mysql_real_escape_string($_POST['dobm']); $doby = mysql_real_escape_string($_POST['datey']); $dobtotal = $doby.'-'.$dobm.'-'.$dobd; $dateofbirth = mysql_real_escape_string($_POST['$dobtotal']); $sql = "INSERT INTO users (id, username, password, city, gender, looking_for, date_of_birth, email) VALUES ('', '$username',SHA1('$password'),'$city','$gender','$lookingfor', '$dobtotal','$email')"; $DBCON = mysql_query($sql, $conn); // ?> Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781071 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 Sorry didnt see the coding symbol ive tried it but it still shows up Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781081 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Try taking out the limit clause and see if it works. Also you can try just echoing $username to the page to see what $username 's value actually is. Let me know what you get. Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781090 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Another thing I noticed is that this line: if (isset($_POST['submit'])) { should be this: if (isset($_POST['Submit'])) { The "s" in the first one should be "S" because you set its name to Submit not submit. Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781096 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 Ok ive taken the limit out and when i try echoin the $username it echos whatever i put into the username input box but when i try echoing the query it just says 1 Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781098 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 When you echo the query it says 1 or when you echo the $count it says 1? Did you try it without entering anything without the limit in there? Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781111 Share on other sites More sharing options...
revraz Posted March 10, 2009 Share Posted March 10, 2009 And it should be empty because you do your Query before you set your $username variable. Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781113 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 yeah i echoed the $count and tried leaving it blank but still nothing Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781117 Share on other sites More sharing options...
revraz Posted March 10, 2009 Share Posted March 10, 2009 Which query are you referring to, $searchQuery or $sql ? Because you never set $username before you call $searchQuery which has your LIMIT 1 clause. Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781123 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Try this: <?php include('mydbfile'); $conn = mysql_connect("$hostname_dbconnect","$username_dbconnect","$password_dbconnect") or die ("cannot connect"); $dbconn = mysql_select_db("$database_dbconnect",$conn) or die ("cannot select DB"); if (isset($_POST['Submit'])) { /////////////////////////////////////////////////////////////////////////////////////// //All the information to be passed to the database. $username = mysql_real_escape_string($_POST['Username']); $password = mysql_real_escape_string($_POST['Password']); $confpass = mysql_real_escape_string($_POST['Confirm password']); $city = mysql_real_escape_string($_POST['City']); $gender = mysql_real_escape_string($_POST['Gender']); $lookingfor = mysql_real_escape_string($_POST['Looking_for']); $email = mysql_real_escape_string($_POST['email']); $emailconf = mysql_real_escape_string($_POST['Confirm E-Mail']); $dobd = mysql_real_escape_string($_POST['dobd']); $dobm = mysql_real_escape_string($_POST['dobm']); $doby = mysql_real_escape_string($_POST['datey']); $dobtotal = $doby.'-'.$dobm.'-'.$dobd; $dateofbirth = mysql_real_escape_string($_POST['$dobtotal']); } else { $username = ""; $password = ""; $confpass = ""; $city = ""; $gender = ""; $lookingfor = ""; $email = ""; $emailconf = ""; $dobd = ""; $dobm = ""; $doby = ""; } ///////////////////////////////////////////////////////////////////////////////////////// $searchQuery ="SELECT username FROM users WHERE username = '$username' LIMIT 1"; $queryFinding = mysql_query($searchQuery); $count = mysql_num_rows($queryFinding); if($count > 0) { $message = "Username is already taken please choose another."; } //$queryResult = mysql_num_rows($queryFinding); $sql = "INSERT INTO users (id,username,password,city,gender,looking_for,date_of_birth,email) VALUES ('','$username',SHA1('$password'),'$city','$gender','$lookingfor','$dobtotal','$email')"; $DBCON = mysql_query($sql, $conn); ?> What was up with the weird characters that it put in place of spaces? I copied and pasted and edited and when I saved it had some #160; or something lol Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781126 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 Just tried and and still no luck Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781131 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 I tested this same code in my environment and it worked fine for me. Where are you using this code? Is it on a server or is it on your local computer running wamp? Whats the environment pretty much is what i am getting at? Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781136 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 Im using Xampp could that be a problem Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781139 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 I think the code may be the problem. Try enabling register globals and see if it works then. Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781147 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 Ive enabled it but still same Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781157 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Can you show me what your code looks like now? Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781171 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 Yeah <?php include('mydbfile'); $conn = mysql_connect("$hostname_dbconnect","$username_dbconnect","$password_dbconnect") or die ("cannot connect"); $dbconn = mysql_select_db("$database_dbconnect",$conn) or die ("cannot select DB"); if (isset($_POST['Submit'])) { /////////////////////////////////////////////////////////////////////////////////////// //All the information to be passed to the database. $username = mysql_real_escape_string($_POST['Username']); $password = mysql_real_escape_string($_POST['Password']); $confpass = mysql_real_escape_string($_POST['Confirm password']); $city = mysql_real_escape_string($_POST['City']); $gender = mysql_real_escape_string($_POST['Gender']); $lookingfor = mysql_real_escape_string($_POST['Looking_for']); $email = mysql_real_escape_string($_POST['email']); $emailconf = mysql_real_escape_string($_POST['Confirm E-Mail']); $dobd = mysql_real_escape_string($_POST['dobd']); $dobm = mysql_real_escape_string($_POST['dobm']); $doby = mysql_real_escape_string($_POST['datey']); $dobtotal = $doby.'-'.$dobm.'-'.$dobd; $dateofbirth = mysql_real_escape_string($_POST['$dobtotal']); } else { $username = ""; $password = ""; $confpass = ""; $city = ""; $gender = ""; $lookingfor = ""; $email = ""; $emailconf = ""; $dobd = ""; $dobm = ""; $doby = ""; } ///////////////////////////////////////////////////////////////////////////////////////// $searchQuery ="SELECT username FROM users WHERE username = '$username'"; $queryFinding = mysql_query($searchQuery); $count = mysql_num_rows($queryFinding); if($count > 0) { $message = "Username is already taken please choose another."; } //$queryResult = mysql_num_rows($queryFinding); $sql = "INSERT INTO users (id,username,password,city,gender,looking_for,date_of_birth,email) VALUES ('','$username',SHA1('$password'),'$city','$gender','$lookingfor','$dobtotal','$email')"; $DBCON = mysql_query($sql, $conn); ?> <!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" xml:lang="en" lang="en"> <head> <title>Chatlol: Coming soon</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="layout.css" rel="stylesheet" type="text/css" /> </head> <body id="page2"> <div id="main"> <!-- header --> <div id="header"> <div class="row_1"> <ul class="menu"> <li><a href="index.php">main page</a></li> <li><a class="current" href="register.php">register</a> <ul> <li><a href="forgotpass.php">forgot pass</a></li> </ul> </li> <li><a href="online.php">members online</a></li> <li><a href="tos.php">terms of service</a></li> <li><a href="faqs.php">faqs</a></li> <li><a class="last" href="mailto:[email protected]">contact me</a></li> </ul> </div> <div class="row_2"> <a href="index.html"><img alt="" src="images/logo.jpg" /></a> </div> </div> <!-- content --> <div id="content"> <div class="col_1"> <div class="box1 p1"> <div class="inner"> <h3>Events calendar</h3> <div class="inner1"></div> </div> </div> <div class="box2"> <div class="inner"> <h3 class="marker5">special news</h3> <div class="inner1"> <h4><?php echo date('d/m/Y'); ?></h4> Chatlol will up and running soon. <div class="block"> <div class="ind"> <h5><a href="#">Aenean nonumysiceres</a></h5> <img alt="" src="images/2page_pic1.jpg" /> </div> </div> <h4><?php echo date('d/m/Y'); ?></h4> The new and upcoming chat site will be here soon.</div> </div> </div> </div> <div class="col_2 indent"> <div class="row_1"> <p> </p> <p><br /> </p> <form method="POST" enctype="multipart/form-data" name="register" id="register"> <table width="290" border="1" class="box3"> <tr> <td width="80"><div align="right"> <label>Username</label> </div></td> <td width="194"><div align="left"> <input name="Username" type="text" id="Username" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><div align="right"> <label>Password</label> </div></td> <td><div align="left"> <input name="Password" type="password" id="Password" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><label> <div align="right">Confirm password</div> </label></td> <td><div align="left"> <input name="Confirm password" type="password" id="Confirm password" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><div align="right"> <label>City</label> </div></td> <td><div align="left"> <input name="City" type="text" id="City" size="33" maxlength="60" /> </div></td> </tr> <tr> <td><div align="right"> <label>Gender</label> </div></td> <td><div align="left"> <select name="Gender" id="Gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> </div></td> </tr> <tr> <td><div align="right"> <div align="right"> <label>Looking for</label> </div> </div></td> <td><div align="left"> <select name="Looking_for" id="Looking_for"> <option value="Friendship">Friendship</option> <option value="Email and Chat">Email and Chat</option> <option value="Relationship">Relationship</option> <option value="Fun">Fun</option> <option value="No strings fun">No strings fun</option> <option value="Other">Other</option> </select> </div></td> </tr> <tr> <td><div align="right"> <label>E-Mail</label> </div></td> <td><div align="left"> <input name="email" type="text" id="email" size="33" maxlength="50" /> </div></td> </tr> <tr> <td><div align="right"> <label>Confirm E-Mail</label> </div></td> <td><div align="left"> <input name="Confirm E-Mail" type="text" id="Confirm E-Mail" size="33" maxlength="50" /> </div></td> </tr> <tr> <td><label> <div align="right">Date of birth</div> </label></td> <td><label> <select name="dobd" id="dobd"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="dobm" id="dobm"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="datey" id="datey"> <option value="1934">1934</option> <option value="1935">1935</option> <option value="1936">1936</option> <option value="1937">1937</option> <option value="1938">1938</option> <option value="1939">1939</option> <option value="1940">1940</option> <option value="1941">1941</option> <option value="1942">1942</option> <option value="1943">1943</option> <option value="1944">1944</option> <option value="1945">1945</option> <option value="1946">1946</option> <option value="1947">1947</option> <option value="1948">1948</option> <option value="1949">1949</option> <option value="1950">1950</option> <option value="1951">1951</option> <option value="1952">1952</option> <option value="1953">1953</option> <option value="1954">1954</option> <option value="1955">1955</option> <option value="1956">1956</option> <option value="1957">1957</option> <option value="1958">1958</option> <option value="1959">1959</option> <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> <option value="1964">1964</option> <option value="1965">1965</option> <option value="1966">1966</option> <option value="1967">1967</option> <option value="1968">1968</option> <option value="1969">1969</option> <option value="1970">1970</option> <option value="1971">1971</option> <option value="1972">1972</option> <option value="1973">1973</option> <option value="1974">1974</option> <option value="1975">1975</option> <option value="1976">1976</option> <option value="1977">1977</option> <option value="1978">1978</option> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> </select> </label></td> </tr> </table> <p> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> </p> <p></p> </form> <h4> </h4> </div> <div class="container row_2"> <div class="column1"></div> <div class="clear"></div> </div> </div> <div class="clear"></div> </div> <!-- footer --> <div id="footer"> <ul class="footer_menu"> <li><a href="#">main page</a></li> <li><a href="#">city</a></li> <li><a href="#">help</a></li> <li><a href="#">events</a></li> <li><a href="#">map</a></li> <li><a href="#">tourism</a></li> <li><a class="last" href="#">Contacts</a></li> </ul> <p>City portal © 2008. <a href="#">Privacy Policy</a></p> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781181 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Just out of curiosity is there a username in the database that is blank (could be multiple entries)? That would explain it. If there is remove it and try again. Change you code to this though first: <?php include('mydbfile'); $conn = mysql_connect("$hostname_dbconnect","$username_dbconnect","$password_dbconnect") or die ("cannot connect"); $dbconn = mysql_select_db("$database_dbconnect",$conn) or die ("cannot select DB"); if (isset($_POST['Submit'])) { /////////////////////////////////////////////////////////////////////////////////////// //All the information to be passed to the database. $username = mysql_real_escape_string($_POST['Username']); $password = mysql_real_escape_string($_POST['Password']); $confpass = mysql_real_escape_string($_POST['Confirm password']); $city = mysql_real_escape_string($_POST['City']); $gender = mysql_real_escape_string($_POST['Gender']); $lookingfor = mysql_real_escape_string($_POST['Looking_for']); $email = mysql_real_escape_string($_POST['email']); $emailconf = mysql_real_escape_string($_POST['Confirm E-Mail']); $dobd = mysql_real_escape_string($_POST['dobd']); $dobm = mysql_real_escape_string($_POST['dobm']); $doby = mysql_real_escape_string($_POST['datey']); $dobtotal = $doby.'-'.$dobm.'-'.$dobd; $dateofbirth = mysql_real_escape_string($_POST['$dobtotal']); } else { $username = ""; $password = ""; $confpass = ""; $city = ""; $gender = ""; $lookingfor = ""; $email = ""; $emailconf = ""; $dobd = ""; $dobm = ""; $doby = ""; } ///////////////////////////////////////////////////////////////////////////////////////// $searchQuery ="SELECT username FROM users WHERE username = '$username'"; $queryFinding = mysql_query($searchQuery); $count = mysql_num_rows($queryFinding); if($count > 0) { $message = "Username is already taken please choose another."; } //$queryResult = mysql_num_rows($queryFinding); else { $sql = "INSERT INTO users (id,username,password,city,gender,looking_for,date_of_birth,email) VALUES ('','$username',SHA1('$password'),'$city','$gender','$lookingfor','$dobtotal','$email')"; $DBCON = mysql_query($sql, $conn); $message = "Data inserted into database"; } ?> <!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" xml:lang="en" lang="en"> <head> <title>Chatlol: Coming soon</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="layout.css" rel="stylesheet" type="text/css" /> </head> <body id="page2"> <div id="main"> <!-- header --> <div id="header"> <div class="row_1"> <ul class="menu"> <li><a href="index.php">main page</a></li> <li><a class="current" href="register.php">register</a> <ul> <li><a href="forgotpass.php">forgot pass</a></li> </ul> </li> <li><a href="online.php">members online</a></li> <li><a href="tos.php">terms of service</a></li> <li><a href="faqs.php">faqs</a></li> <li><a class="last" href="mailto:[email protected]">contact me</a></li> </ul> </div> <div class="row_2"> <a href="index.html"><img alt="" src="images/logo.jpg" /></a> </div> </div> <!-- content --> <div id="content"> <div class="col_1"> <div class="box1 p1"> <div class="inner"> <h3>Events calendar</h3> <div class="inner1"></div> </div> </div> <div class="box2"> <div class="inner"> <h3 class="marker5">special news</h3> <div class="inner1"> <h4><?php echo date('d/m/Y'); ?></h4> Chatlol will up and running soon. <div class="block"> <div class="ind"> <h5><a href="#">Aenean nonumysiceres</a></h5> <img alt="" src="images/2page_pic1.jpg" /> </div> </div> <h4><?php echo date('d/m/Y'); ?></h4> The new and upcoming chat site will be here soon.</div> </div> </div> </div> <div class="col_2 indent"> <div class="row_1"> <p> </p> <p><br /> </p> <form method="POST" enctype="multipart/form-data" name="register" id="register"> <table width="290" border="1" class="box3"> <tr> <td width="80"><div align="right"> <label>Username</label> </div></td> <td width="194"><div align="left"> <input name="Username" type="text" id="Username" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><div align="right"> <label>Password</label> </div></td> <td><div align="left"> <input name="Password" type="password" id="Password" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><label> <div align="right">Confirm password</div> </label></td> <td><div align="left"> <input name="Confirm password" type="password" id="Confirm password" size="33" maxlength="20" /> </div></td> </tr> <tr> <td><div align="right"> <label>City</label> </div></td> <td><div align="left"> <input name="City" type="text" id="City" size="33" maxlength="60" /> </div></td> </tr> <tr> <td><div align="right"> <label>Gender</label> </div></td> <td><div align="left"> <select name="Gender" id="Gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> </div></td> </tr> <tr> <td><div align="right"> <div align="right"> <label>Looking for</label> </div> </div></td> <td><div align="left"> <select name="Looking_for" id="Looking_for"> <option value="Friendship">Friendship</option> <option value="Email and Chat">Email and Chat</option> <option value="Relationship">Relationship</option> <option value="Fun">Fun</option> <option value="No strings fun">No strings fun</option> <option value="Other">Other</option> </select> </div></td> </tr> <tr> <td><div align="right"> <label>E-Mail</label> </div></td> <td><div align="left"> <input name="email" type="text" id="email" size="33" maxlength="50" /> </div></td> </tr> <tr> <td><div align="right"> <label>Confirm E-Mail</label> </div></td> <td><div align="left"> <input name="Confirm E-Mail" type="text" id="Confirm E-Mail" size="33" maxlength="50" /> </div></td> </tr> <tr> <td><label> <div align="right">Date of birth</div> </label></td> <td><label> <select name="dobd" id="dobd"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="dobm" id="dobm"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="datey" id="datey"> <option value="1934">1934</option> <option value="1935">1935</option> <option value="1936">1936</option> <option value="1937">1937</option> <option value="1938">1938</option> <option value="1939">1939</option> <option value="1940">1940</option> <option value="1941">1941</option> <option value="1942">1942</option> <option value="1943">1943</option> <option value="1944">1944</option> <option value="1945">1945</option> <option value="1946">1946</option> <option value="1947">1947</option> <option value="1948">1948</option> <option value="1949">1949</option> <option value="1950">1950</option> <option value="1951">1951</option> <option value="1952">1952</option> <option value="1953">1953</option> <option value="1954">1954</option> <option value="1955">1955</option> <option value="1956">1956</option> <option value="1957">1957</option> <option value="1958">1958</option> <option value="1959">1959</option> <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> <option value="1964">1964</option> <option value="1965">1965</option> <option value="1966">1966</option> <option value="1967">1967</option> <option value="1968">1968</option> <option value="1969">1969</option> <option value="1970">1970</option> <option value="1971">1971</option> <option value="1972">1972</option> <option value="1973">1973</option> <option value="1974">1974</option> <option value="1975">1975</option> <option value="1976">1976</option> <option value="1977">1977</option> <option value="1978">1978</option> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> </select> </label></td> </tr> </table> <p> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> </p> <p></p> </form> <h4> </h4> </div> <div class="container row_2"> <div class="column1"></div> <div class="clear"></div> </div> </div> <div class="clear"></div> </div> <!-- footer --> <div id="footer"> <ul class="footer_menu"> <li><a href="#">main page</a></li> <li><a href="#">city</a></li> <li><a href="#">help</a></li> <li><a href="#">events</a></li> <li><a href="#">map</a></li> <li><a href="#">tourism</a></li> <li><a class="last" href="#">Contacts</a></li> </ul> <p>City portal © 2008. <a href="#">Privacy Policy</a></p> </div> </div> </body> </html> All I did was change it so the insert query only goes if the username doesnt exist. You would also wanna do it so that if it is blank it doesnt enter but you can try it at least once with this. Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781186 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 Everything is being inserted to the database but the messages arent coming up to say when they have registered or if theres 2 usernames i cleared the database theres no blanks Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781198 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Just by looking at the code again the message isnt getting shown because somewhere down this long road it looks like we stopped echoing out the $message. Just put that back in and it should. If you insert a username that is already there does it still insert it in the database? Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781205 Share on other sites More sharing options...
chatmaster Posted March 10, 2009 Author Share Posted March 10, 2009 yeah do it finally really appreciate ur help Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781214 Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 No problem thats what were here for. If your topic is solved please mark it as solved. Link to comment https://forums.phpfreaks.com/topic/148756-solved-registration-problem/#findComment-781216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.