I have home.php and I am trying to pass two php variables in an onclick() function. But it does not work. I am new in php so any suggestion will be very helpful.
<form action="process/home.php" method="post">
<input type="text" name="userfrom" value="<?php echo htmlspecialchars($username); ?>"/>
<input type="submit" onclick=show('$user_id','$_SESSION['id']') value="Add Friend"/>
</form>
In the show() function I wanted to store the values in the database.
function show($userfrom,$userto){
$sql="INSERT INTO user (userfrom,userto) VALUES ('$userfrom','$userto')";
mysql_query($sql);
<!--it is not working-->
}