Twysted Posted March 11, 2007 Share Posted March 11, 2007 ok i have tried all i can think of MySQL Version: 5.0.27-standard PHP Version: 4.4.4 PHPMyAdmin Version: phpMyAdmin - 2.9.0.2 my register script: <?php include( "includes/inc-header.php" ); echo "<br>"; if ( !$_GET['stp'] ) { ?> <form action="register.php?stp=2" method="post"> <table width="60%" border="0" align="center"> <tr><td colspan="4" class="bodycell3">Register</td></tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Username:</b></td> <td class="bodycell4" width="50%" align="center"><input name="username" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" colspan="2" align="right">Your username may be between 5 - 16 Characters.</td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Password:</b></td> <td class="bodycell4" width="50%" align="center"><input name="password1" type="password" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Re-type Password:</b></td> <td class="bodycell4" width="50%" align="center"><input name="password2" type="password" size="30"></td> </tr> <tr> <td class="bodycell4" colspan="2" align="right">Your password may be between 5 - 10 Characters.</td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Email:</b></td> <td class="bodycell4" width="50%" align="center"><input name="email1" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Re-type Email:</b></td> <td class="bodycell4" width="50%" align="center"><input name="email2" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" colspan="2" align="right">Email must be correct as you need to validate your account.</td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>First Name:</b></td> <td class="bodycell4" width="50%" align="center"><input name="firstname" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Last Name:</b></td> <td class="bodycell4" width="50%" align="center"><input name="lastname" type="text" size="30"></td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Gender:</b></td> <td class="bodycell4" width="50%" align="center"> <select name="gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> </td> </tr> <tr> <td class="bodycell4" width="50%" align="right"><b>Race:</b></td> <td class="bodycell4" width="50%" align="center"> <select name="race"> <option value="1"><?=$SETTINGS['prace_1']?></option> <option value="2"><?=$SETTINGS['prace_2']?></option> <option value="3"><?=$SETTINGS['prace_3']?></option> <option value="4"><?=$SETTINGS['prace_4']?></option> <option value="5"><?=$SETTINGS['prace_5']?></option> <option value="6"><?=$SETTINGS['prace_6']?></option> </select> </td> </tr> <tr> <td class="bodycell4" colspan="2"> Races start with:<br> -><?=$SETTINGS['prace_1']?>: +2500 Defense, +2500 Offense, +15000 Gold<br> -><?=$SETTINGS['prace_2']?>: +5 Army, +40000 Gold<br> -><?=$SETTINGS['prace_3']?>: +5000 Offense, +2500 Defense<br> -><?=$SETTINGS['prace_4']?>: +7500 Defense<br> -><?=$SETTINGS['prace_5']?>: +7500 Offense<br> -><?=$SETTINGS['prace_6']?>: +5000 Offense, +25000 Gold<br> </td> </tr> <tr> <td colspan="4" class="bodycell4"> <center> <input name="register" type="submit" value="Register"> </center> </td> </tr> </table> </form> <?php } elseif ( $_GET['stp'] == 2 ) { $username = htmlentities( stripslashes( $_POST['username'] ) ); $password1 = stripslashes( $_POST['password1'] ); $password2 = stripslashes( $_POST['password2'] ); $email1 = strip_tags( stripslashes( $_POST['email1'] ) ); $email2 = strip_tags( stripslashes( $_POST['email2'] ) ); $firstname = htmlentities( stripslashes( $_POST['firstname'] ) ); $lastname = htmlentities( stripslashes( $_POST['lastname'] ) ); $gender = htmlentities( stripslashes( $_POST['gender'] ) ); $race = htmlentities( stripslashes( $_POST['race'] ) ); $utaken = $db->fetch( $db->query( "SELECT * FROM users WHERE uLogin=\"$username\"" ) ); $etaken = $db->fetch( $db->query( "SELECT * FROM users WHERE uEmail=\"$email1\"" ) ); echo "<center>"; if ( strlen( $username ) < 5 ) { echo "$username is too long."; } elseif ( strlen( $username ) > 16 ) { echo "Your username is too long."; } elseif ( $utaken ) { echo "The username you entered is already in use."; } elseif ( $password1 != $password2 ) { echo "The passwords entered do not match."; } elseif ( strlen( $password1 ) < 5 ) { echo "Your password is too short."; } elseif ( strlen( $password1 ) > 10 ) { echo "Your password is too long."; } elseif ( $email1 != $email2 ) { echo "The emails entered do not match."; } elseif ( $etaken ) { echo "The email you entered is already in use."; } else { if ( !$firstname ) { $firstname = "n/a"; } if ( !$lastname ) { $lastname = "n/a"; } if ( $race == 1 ) { $citizens = "3"; $gold = "40000"; $offense = "7500"; $defense = "7500"; } elseif ( $race == 2 ) { $citizens = "8"; $gold = "65000"; $offense = "5000"; $defense = "5000"; } elseif ( $race == 3 ) { $citizens = "3"; $gold = "25000"; $offense = "10000"; $defense = "7500"; } elseif ( $race == 4 ) { $citizens = "3"; $gold = "25000"; $offense = "5000"; $defense = "12500"; } elseif ( $race == 5 ) { $citizens = "3"; $gold = "25000"; $offense = "12500"; $defense = "5000"; } elseif ( $race == 6 ) { $citizens = "3"; $gold = "50000"; $offense = "10000"; $defense = "5000"; } $randcode = rand( 1000, 9999 ) . "-" . rand( 1000, 9999 ) . "-" . rand( 100, 999 ); $querydb = "INSERT INTO `users` "; $querydb .= "( `uEmail` , `uLogin` , `uPassword` , `uFirstName` , `uLastName` , `uGender` , `uCode` , `uRace` , `uGold` , `uCitizens` , `uOffensiveMen` , `uDefensiveMen` , `uMiners` , `uOffense` , `uDefense` ) "; $querydb .= "VALUES ('NULL, '$email1', '$username', '$password1', '$firstname', '$lastname', '$gender', '$randcode', '$race', '$gold', '$citizens', '5', '5', '1', '$offense', '$defense')"; $db->query( $querydb ); $linsrt = mysql_insert_id(); $db->query( "INSERT INTO `users_online` (`uID`,`uIPAddress`,`uCode`) VALUES (\"LOL - $linsrt\",\"" . $REMOTE_ADDR . "\",\"logged_out\")" ); $x = 1; $YourRegLink = $SETTINGS['game_url'] . "validate2.php?email=" . $email1 . "&code=" . $randcode; $TheSender = $SETTINGS['game_email']; $TheRecipient = $email1; $TheSubject = $SETTINGS['gamename'] . ": Validation Code"; $TheText = "<font face='Tahoma' size='1'>Dear " . $username . ",<br>Welcome to " . $SETTINGS['gamename'] . ". <BR> You will need to type in the following confirmation code on the website, before you can play " . $SETTINGS['gamename'] . ".<br> <br> REG-CODE: " . $randcode . "<br> <br> Or you can click the following link:<br> <a href='" . $YourRegLink . "'>" . $YourRegLink . "</a><BR><BR>"; $TheText = $TheText . "Or, you could copy and paste the following url into your browser:<BR>" . $YourRegLink . "</font>"; $TheText = $TheText . "<BR><BR>"; $TheText = $TheText . "Any replies to this email will be automatically deleted."; $TheText2 = "Dear " . $username . ",\r\nWelcome to " . $SETTINGS['gamename'] . ". \r\n You will need to type in the following confirmation code on the website, before you can play " . $SETTINGS['gamename'] . ".\r\n\r\n REG-CODE: " . $randcode . "\r\n \r\n"; $TheText2 = $TheText . "Or, you could copy and paste the following url into your browser:\r\n" . $YourRegLink; $TheText2 = $TheText . "\r\n\r\n"; $TheText2 = $TheText . "Any replies to this email will be automatically deleted."; $headers = "From: $TheSender\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $boundary = uniqid( "hbsignup" ); $headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n"; $headers .= "$TheText2\r\n\r\n"; $headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split( base64_encode( $TheText2 ) ); $headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split( base64_encode( $TheText ) ); if ( mail( $email1, $TheSubject, "", $headers ) ) { ?> Your confirmation code has been sent.<BR> Once you have received your code, <A HREF='validate.php'>click here</A> to activate your account. <?php } else { ?> You have to <h5><A HREF="validate2.php?email=<?php echo $email1; ?>&code=<?php echo $randcode; ?>"><B>ACTIVATE</B></A></h5> your account, before you can play.<BR> Please activate your account, by <A HREF="validate2.php?email=<?php echo $email1; ?>&code=<?php echo $randcode; ?>"><B>CLICKING HERE</B></A>.<BR> From there, you can login. <BR> <?php } } if ( !$x ) { echo "<br><br>"; echo "<a href=\"javascript:history.back();\">BACK</a>"; } echo "</center>"; } include( "includes/inc-footer.php" ); ?> it send email and goes to step 2 but doesn't insert into database Quote Link to comment https://forums.phpfreaks.com/topic/42205-solved-script-wont-insert-into-mysql/ Share on other sites More sharing options...
JasonLewis Posted March 11, 2007 Share Posted March 11, 2007 are you getting errors? try adding: or die("Error: ".mysql_error()); onto the end of your query statement. Quote Link to comment https://forums.phpfreaks.com/topic/42205-solved-script-wont-insert-into-mysql/#findComment-204723 Share on other sites More sharing options...
Twysted Posted March 11, 2007 Author Share Posted March 11, 2007 no errors Quote Link to comment https://forums.phpfreaks.com/topic/42205-solved-script-wont-insert-into-mysql/#findComment-204737 Share on other sites More sharing options...
xyn Posted March 11, 2007 Share Posted March 11, 2007 Well I've noticed a problem with your coding. if ( mail( $email1, $TheSubject, "", $headers ) ) { anything like that. May cause errors. i found if( "word" == "var" ){ Caused problems where as... if("word"=="var"){ doesn't cause problems. Basically what i am saying is try removing ALL the SPACES in your coding on Functions, and if statements etc. Quote Link to comment https://forums.phpfreaks.com/topic/42205-solved-script-wont-insert-into-mysql/#findComment-204739 Share on other sites More sharing options...
Twysted Posted March 11, 2007 Author Share Posted March 11, 2007 even on php 5? Quote Link to comment https://forums.phpfreaks.com/topic/42205-solved-script-wont-insert-into-mysql/#findComment-204742 Share on other sites More sharing options...
Twysted Posted March 11, 2007 Author Share Posted March 11, 2007 ok that didn't help Quote Link to comment https://forums.phpfreaks.com/topic/42205-solved-script-wont-insert-into-mysql/#findComment-204751 Share on other sites More sharing options...
Twysted Posted March 11, 2007 Author Share Posted March 11, 2007 nevermind i fixed it Quote Link to comment https://forums.phpfreaks.com/topic/42205-solved-script-wont-insert-into-mysql/#findComment-204755 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.