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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.