1

I have this from on my index file:

<form action="index.php#updateMatch" method="post">
    <?php
        Some select option
        echo '&nbsp;&nbsp;Date: (AAAA-MM-JJ) <input type="date" name="datematch">';
    ?>
    <input type="submit" value="do somthing" />
</form>

And if I some $_POST[xxx] I call this function:

function updateMatch($id,
    $winner_id, 
    $looser_id,
    $character_winner_id, 
    $character_looser_id, 
    $date) {
    database conection......
    $updatematch="UPDATE `match` SET manythings and date=$_POST[datematch] WHERE id=$_POST[id];";
    echo 'match.... N°'.$_POST['id'];
    mysql_close($db);
    }
    else 
        {echo "<span style='color: red'>blablabla</span>";}
}

But for date, the update dont work, the function set date to: 0000-00-00. How can i update date to ? Thanks

John Conde
  • 217,595
  • 99
  • 455
  • 496
user3414480
  • 115
  • 1
  • 2
  • 7

1 Answers1

2

For starters you are missing quotes around your date:

$updatematch="UPDATE `match` SET manythings and date=$_POST[datematch] WHERE id=$_POST[id];";

should be:

$updatematch="UPDATE `match` SET manythings and date='$_POST[datematch]' WHERE id=$_POST[id];";

You also have an unecessary column in your statement (manythings). Remove it or fix it (I removed it because I don't know of a valid value to use):

$updatematch="UPDATE `match` SET date='$_POST[datematch]' WHERE id=$_POST[id];";

You are wide open to SQL injections

Community
  • 1
  • 1
John Conde
  • 217,595
  • 99
  • 455
  • 496