Harshad Patel
Harshad Patel

Reputation: 9

How to update radio button's data to mysql database with php?

CODE am trying:

what about update radio button's logic ?? Is this OK ??

            if(isset($_POST['btnSubmit']))
{   
    $book_save = $_POST['book_title'];
    $author_save = $_POST['author_name'];
    $gender_save = $_POST['gender'];

    mysql_query("UPDATE bookss SET book_title ='$book_save',author_name ='$author_save',gender='$gender_save' WHERE ID = '$id'")
                or die(mysql_error());

i refer 2 links in SO but m not getting properly with radio button .... Suggestions are always Welcome ...

Upvotes: 0

Views: 1250

Answers (2)

user1991510
user1991510

Reputation:

I agree with everyone above, are you hard coding the radio button values? if so, I'm not sure how SQL injection would effect radio button entries. In any case, if you're stuck to this structure I'd at least do something like this: $book_save = mysql_real_escape_string($_POST['book_title']);

Upvotes: 1

SeanWM
SeanWM

Reputation: 16989

What you're doing is correct. I would suggest you escape your data though. You're open to sql injection. I'd also look into using PDO as the mysql functions are deprecated.

Upvotes: 0

Related Questions