GetReady Posted April 5, 2010 Share Posted April 5, 2010 The following code isn't updating the "class" field to 1 as i intend nor does it take the user to welcome.php like i intended any clues? <? if($submit) { $sql = "INSERT INTO users (class) VALUES ('1')"; $result = mysql_query($sql); } ?> <form method="post" action="welcome.php"> <input type="Submit" name="submit" value="Choose"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/197579-any-clue-whats-going-wrong-here/ Share on other sites More sharing options...
oni-kun Posted April 5, 2010 Share Posted April 5, 2010 A) You're using short tags. B) You're not using isset on $submit. C) You want handling of the form on welcome.php, Not the current page. D) Your obviously incorrect parentheses on the SQL statement. Quote Link to comment https://forums.phpfreaks.com/topic/197579-any-clue-whats-going-wrong-here/#findComment-1036936 Share on other sites More sharing options...
ignace Posted April 5, 2010 Share Posted April 5, 2010 D) Your obviously incorrect parentheses on the SQL statement. incorrect parentheses? which parentheses should they then be using? I also want to add: E) Relying on register_globals Quote Link to comment https://forums.phpfreaks.com/topic/197579-any-clue-whats-going-wrong-here/#findComment-1037053 Share on other sites More sharing options...
Lukeidiot Posted April 5, 2010 Share Posted April 5, 2010 If you want that to work try this... <?php if(isset($_POST['submit'])) { mysql_query("INSERT INTO users ('class') VALUES ('1')"); } ?> <form method="post" action=""> <input type="Submit" name="submit" value="Choose"> </form> Even though I have no idea why you have a form when you are inserting data directly "1" into class. Quote Link to comment https://forums.phpfreaks.com/topic/197579-any-clue-whats-going-wrong-here/#findComment-1037056 Share on other sites More sharing options...
GetReady Posted April 5, 2010 Author Share Posted April 5, 2010 Ahh maybe im going about it in the wrong way? Im unsure basically theres 4 options each class is 1, 2, 3, 4 so i need a submit button for each, so when the button is submitted what ever class was chosen is submitted to the database, The above code you helped with still didn't update the database, im really unsure as to why, Any help would be great, Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/197579-any-clue-whats-going-wrong-here/#findComment-1037231 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.