3raser Posted February 8, 2011 Share Posted February 8, 2011 For some reason it just stopped working. It was fine earlier. I don't even think I messed with it. :/ mysql_query("INSERT INTO apps VALUES ('', '$username', '$age', '$why', '$ip', '$random', '$id', '0')"); The data wont go in the database for some reason. Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Share Posted February 8, 2011 Does it give an error? or does it say 'Submitted' as usual but just doesn't submit? Quote Link to comment Share on other sites More sharing options...
3raser Posted February 8, 2011 Author Share Posted February 8, 2011 Does it give an error? or does it say 'Submitted' as usual but just doesn't submit? It says it was submitted but it doesn't go through. :/ Quote Link to comment Share on other sites More sharing options...
3raser Posted February 8, 2011 Author Share Posted February 8, 2011 Anyone? Full code: <?php include("config.php"); if(!$_GET['id'] || $_POST['id']) { $id = $_POST['id']; } else { $id = $_GET['id']; } if(!$id) { echo "You haven't selected a server you'd like to join! <a href='index.php'>Home</a>"; } else { $username = mysql_real_escape_string($_POST['username']); $age = mysql_real_escape_string($_POST['age']); $why = mysql_real_escape_string($_POST['why']); $sql = mysql_query("SELECT title,closed,id,username FROM servers WHERE id='$id'"); if(!mysql_num_rows($sql)) { echo "No such server exists!"; } elseif(!$_POST['username'] || !$_POST['age'] || !$_POST['why']) { echo "Your Minecraft username: <form action='join.php' method='POST'><input type='text' name='username'> <input type='hidden' name='id' value='". $id ."'><br/><br/> Your age: <br/><input type='text' name='age'><br/><br/> Why should we accept you:<br/><textarea rows='15' cols='25' name='why' maxlength='250'></textarea><br/><input type='submit'> </form>"; } elseif(is_numeric($age)) { $ip = $_SERVER['REMOTE_ADDR']; $random = md5($why.$ip.$id.$age.$username); mysql_query("INSERT INTO apps VALUES ('', '$username', '$age', '$why', '$ip', '$random', '$id', '0')"); echo "Whitelist application sent!<br/> If you wisht to check the status, write down this code: <b>". $random ."</b> <a href='index.php'>Home</a>"; } else { echo "Age must be numbers only! Click back in your browser."; } } ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 Probably a good time to throw in some logic to see what the query is actually doing. $ip = $_SERVER['REMOTE_ADDR']; $random = md5($why.$ip.$id.$age.$username); $query = "INSERT INTO apps VALUES ('', '$username', '$age', '$why', '$ip', '$random', '$id', '0')"; if( $result = mysql_query($query) ) { if( mysql_affected_rows() < 1 ) { echo '<br>Query ran, but no record was inserted<br>'; } } else { echo "<br>Query string: $query<br>Produced error: " . mysql_error() . '<br>'; } echo "Whitelist application sent!<br/> If you wisht to check the status, write down this code: <b>". $random ."</b> <a href='index.php'>Home</a>"; 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.