HmmZ 0 Report post Posted March 27, 2005 im just gonna show you the 2 files i use, please help me out, its giving an error i made in the reguser file.The Form <table border="0" width="500" border="0" align="center" valign="top"><form method="post" action="Users/reguser.php" valign="top"> <tr> <th width="81" align="left" valign="top"><div align="left" valign="top"><font size="2">Username:</div></th> <td width="152" align="center" valign="top"><input name="username" type="text" STYLE="color: #D80202; font-weight: bold; font-size: 12px;background-color: #000000;"><br><br></td> </tr> <tr> <th width="81" valign="top"><div align="left" valign="top"><font size="2">Password:</div></th> <td width="152" align="center"><input name="password" type="password" value="" STYLE="color: #D80202; font-weight: bold; font-size: 12px;background-color: #000000;"></td> </tr> <tr> <th width="81" valign="top"><div align="left" valign="top"><font size="2">Confirm Password:</div></th> <td width="152" align="center"><input name="password2" type="password" value="" STYLE="color: #D80202; font-weight: bold; font-size: 12px;background-color: #000000;"><br><br></td> </tr> <th width="81" valign="top"><div align="left" valign="top"><font size="2">Full Name:</div></th> <td width="152" align="center"><input name="fullname" type="text" value="" STYLE="color: #D80202; font-weight: bold; font-size: 12px;background-color: #000000;"></td> </tr> <tr><th width="81" valign="top"><div align="left" valign="top"><font size="2">Gender:</div></th> <td width="152" align="center"><input name="gender" type="radio" value="1" checked><font size="2"><b>Male<input name="gender" type="radio" value="2">Female</td> </tr> <tr><th width="81" valign="top"><div align="left" valign="top"><font size="2">Birth Date:[dd/mm/yyyy]</div></th> <td align="center"><font size="2"><b>Day<select name="birthday" style="background-color: #000000;font size=10; color:#D80202; text-decoration: bold;" size="1" border="0"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</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><font size="2">Month<select name="birthmonth" style="background-color: #000000;font size=10; color:#D80202" size="1" border="0"><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select><font size="2">Year<select name="birthyear" style="background-color: #000000;font size=10; color:#D80202" size="1" border="0"><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option></select></td> </tr> <th width="81" valign="top"><div align="left" valign="top"><font size="2">Country:</div></th> <td width="152" align="center"><input name="country" type="text" value="" STYLE="color: #D80202; font-weight: bold; font-size: 12px;background-color: #000000;"><br><br></td> </tr> <th width="81" valign="top"><div align="left" valign="top"><font size="2">E-Mail:</div></th> <td width="152" align="center"><input name="email" type="text" value="" STYLE="color: #D80202; font-weight: bold; font-size: 12px;background-color: #000000;"></td> </tr> <th width="81" valign="top"><div align="left" valign="top"><font size="2">Confirm E-Mail:</div></th> <td width="152" align="center"><input name="email2" type="text" value="" STYLE="color: #D80202; font-weight: bold; font-size: 12px;background-color: #000000;"><br><br><center><input type="image" src="images/go_register_reg.gif" value="submit" border="0"></center></td> </tr></form></center></table></table> Probably a very confusing script, but it gives me exactly what I want on the register page, just keep the input field names and values in mind for next script. <?phpinclude "connect.php";include "*******";include "*******";if ($_POST){extract($_POST);if ($password!=$password2) { print "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>Your Confirm Password didn't match the original password</b><br><A HREF='javascript:history.back()'><img src='online.trap17.com/****/****/go_backbutton.gif&%2339; border='0'></A></td></tr></table>";}elseif ($email!=$email2) { print "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>Your Confirm E-Mail didn't match the original E-Mail</b><br><A HREF='javascript:history.back()'><img src='online.trap17.com/****/****/go_backbutton.gif&%2339; border='0'></A></td></tr></table>";}elseif ($username==''||$password==''||$fullname==''||$country==''||$email=='') { print "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>You did not fill out all the fields</b><br><A HREF='javascript:history.back()'><img src='online.trap17.com/****/****/go_backbutton.gif&%2339; border='0'></A></td></tr></table>";}else { $password=md5($password); $SQL = "INSERT into go_logintable(username, password, fullname, gender, birthday, birthmonth, birthyear, country, email) VALUES ('$username','$password','{$fullname}','{$gender}','{$birthday}','{$birthmonth}','{$birthyear}','{$country}','{$email}')"; if (!$SQL) { echo "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>registration successful</b></td></tr></table>";}else { echo "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>Registration process was interrupted</b><br><A HREF='javascript:history.back()'><img src='online.trap17.com/****/****/go_backbutton.gif&%2339; border='0'></A></td></tr></table>";}}}?> the error "Registration process was interrupted" keeps popping up, meaning the sql query didnt go well, so I looked in the query, and after some other thread where I asked for help for that, it should be fine now...So couldn't it be your database then?Maybe, this is the create function I used: create table go_logintable( ID int(10) NOT NULL auto_increment, username varchar(20) NOT NULL unique, password varchar(20) NOT NULL, fullname varchar(40) NOT NULL, gender int(1) NOT NULL, birthday int(2) NOT NULL, birthmonth int(2) NOT NULL, birthyear int(4) NOT NULL, country varchar(25) NOT NULL, email varchar(50) NOT NULL, PRIMARY KEY (ID)) Hope you guys can help me.. Share this post Link to post Share on other sites
round 0 Report post Posted March 28, 2005 I realise that the posting thing is a pain, but i wish you wouldn't post your code. It's really a waste of time. You could put the link to file instead which would be much more helpful.round Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted March 28, 2005 I think I see the problem. All of your if statements check to make sure the data was entered correctly. If it was, you then define a variable $SQL which holds the query instruction for sql. Then you check if the variable exists, and if it doesn't display success and if it does, display failure. But you never connect to the database or execute the the query. What I would do is right after defining deifning $SQL insert this code: $resourceID = mysql_connect("localhost", "yourusername", "yourpassword");if (!$resourceID) { die("Error" . mysql_error());}$database = mysql_query("use yourdatabase", $resourceId);if (!$database) { die("Error" . mysql_error());}$success = null; //make success a null variable, you can also define it to false insteadif ($resourceID) { $success = mysql_query("$SQL", $resourceID);} yourusername and yourpassword are the username and password you use to access the mysql database. yourdatabase is the name of the database to take the data.Then change the final if statements in your code to if($success) instead of if(!$SQL)Hope this helps. Share this post Link to post Share on other sites
HmmZ 0 Report post Posted March 28, 2005 $database = mysql_query("use //my db", $resourceId);if (!$database) {die("Error2" . mysql_error());}is the error now i put it right after $SQL: else { $password=md5($password); $SQL="INSERT into go_logintable(username, password, fullname, gender, birthday, birthmonth, birthyear, country, email) VALUES ('{$username}','{$password}','{$fullname}','{$gender}','{$birthday}','{$birthmonth}','{$birthyear}','{$country}','{$email}')"; $resourceID = mysql_connect("localhost", "*****", "*****");if (!$resourceID) {die("Error1" . mysql_error());}$use = mysql_query("use ******", $resourceId);if (!$use) {die("Error2" . mysql_error());}$success = null; //make success a null variable, you can also define it to false insteadif ($resourceID) {$success = mysql_query("$SQL", $resourceID);} } Share this post Link to post Share on other sites
HmmZ 0 Report post Posted March 28, 2005 BTW, before you say it, I also tried instead of: $use = mysql_query("use ******", $resourceId);if (!$use) {die("Error2" . mysql_error());} $database = mysql_query("******", $resourceId);if (!$database) {die("Error2" . mysql_error());} I just used $use instead of $database because ive read before that $database can't be used or something.. Share this post Link to post Share on other sites
FaLgoR 0 Report post Posted March 28, 2005 BTW, before you say it, I also tried instead of: $use = mysql_query("use ******", $resourceId);if (!$use) {die("Error2" . mysql_error());} $database = mysql_query("******", $resourceId);if (!$database) {die("Error2" . mysql_error());} I just used $use instead of $database because ive read before that $database can't be used or something.. 65480[/snapback] Are you sure about this? I always use $database, and it doesn't show any problems. Share this post Link to post Share on other sites
HmmZ 0 Report post Posted March 28, 2005 *BUMP*:)Hope I could get a reply(answer) soon, cause my registration is stuck right now. Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted March 28, 2005 What is the text of the error message you are receiving? And if the Xisto setup is like the Xisto setup, then the name of the database will be "cpanelusername_databasename". Share this post Link to post Share on other sites
HmmZ 0 Report post Posted March 28, 2005 Well...I started all over, writing the whole thing all over again (it was getting confusing), BUT, of course, it's not working It does give me the errors i worked on (passwords dont match, emails dont match, didnt fill everything out) and it gave me the success message, the only problem now is...it doesnt insert the info in the table :)so here is, once more (HOPEFULLY!), my register_user page: <?phpinclude "http://forums.xisto.com/no_longer_exists/ "http://forums.xisto.com/no_longer_exists/ Variables$host="localhost";$user="***";$pass="***";$db="***";$table="***";//registration shortcuts$username=$_POST['username'];$password=$_POST['password'];$password2=$_POST['password2'];$fullname=$_POST['fullname'];$gender=$_POST['gender'];$birthday=$_POST['birthday'];$birthmonth=$_POST['birthmonth'];$birthyear=$_POST['birthyear'];$country=$_POST['country'];$email=$_POST['email'];$email2=$_POST['email2'];if ($password!=$password2) { print "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>Your Confirm Password didn't match the original password</b><br><A HREF='javascript:history.back()'><img src='http://forums.xisto.com/no_longer_exists/; border='0'></A></td></tr></table>";}if ($email!=$email2) { print "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>Your Confirm E-Mail didn't match the original E-Mail</b><br><A HREF='javascript:history.back()'><img src='http://forums.xisto.com/no_longer_exists/; border='0'></A></td></tr></table>";}if ($username==''||$password==''||$fullname==''||$country==''||$email=='') { print "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>You did not fill out all the fields</b><br><A HREF='javascript:history.back()'><img src='http://forums.xisto.com/no_longer_exists/; border='0'></A></td></tr></table>";}//Connect..mysql_connect($host,$user,$pass) or die(mysql_error());mysql_select_db($db) or die(mysql_error());$password=md5($password);$addit="INSERT into $table VALUES ('$username','$password','$fullname','$gender','$birthday','$birthmonth','$birthyear','$country','$email')"; mysql_query($addit);print "<table border='0' align='center' valign='center' width='400' height='400'><tr><td align='center'><font size='2'><b>Registration was succesfull, you can now log in</b></td></tr></table>";}?>I think there must be a problem in the connect part...=/ Share this post Link to post Share on other sites
HmmZ 0 Report post Posted March 29, 2005 *BUMP*Hopefully someone can give me a fix on this, im still thinking it's in the connect part (registration works now, but it wont insert it into the database) Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted March 29, 2005 I would let the mysql_connect() store it's reosurce as a variable and use that resource in every my_sql query(). I woudl also replace mysql_select_db() with mysql_query("use $db) becuase select_db is deprecated while the query is not. And make sure that you are filling up every column in your table. If you have an auto incremented column, like the member ID, then you need to change the INSERT statement to this: "INSERT into $table(username,password,fullname,gender,birthday,birthmonth,birthyear,country,email) ('$username','$password','$fullname','$gender','$birthday','$birthmonth','$birthyear','$country','$email')" where the stuff in the first parenthesis is the names of all the columns you will be filling. Also, try sticking a die("$addit"); right after you define addit to make sure $addit is set the way it is supposed to be. Share this post Link to post Share on other sites
HmmZ 0 Report post Posted March 29, 2005 Finally,its inserting data now, can you explain something to me tho, ive made a testpage to view the data in a table, and I see that the password is way different then I inputted, is this security?($password=md5($password)?Anywayz, big thanks for helping me out, seems its working now, gonna try logging in now Share this post Link to post Share on other sites
mobious 0 Report post Posted March 30, 2005 i think md5 hashing is standard way of security. the password is different from the inputed one because md5() calculates the md5 hash of the string using the md5 algorithm. so the returned value is a unique 32-character hexadecimal number. so when comparing the the stored password during login, you should hash the password again then comapare. Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted March 30, 2005 That's the reason why. The md5() function called on the password before it is input into the table is the reason it does not match the password you entered. Share this post Link to post Share on other sites