Jump to content

Any clue whats going wrong here?


GetReady

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/197579-any-clue-whats-going-wrong-here/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.