I'm traying to update data into mysql database using a javascript function.When I click on a label, this function would call an other function in php to do updating this data. if I click on a label the code would do the stuff. Can you help me please?
I've tried to insert data in my sql table phone by calling publicatePhone php function but no data inserted. here is my code:
**Javascript function:
function answer1yes(clicked) {
var s = document.getElementById("answer1oui").checked;
if (s = "true"){
<?php include('functions.php'); ?>
var x="<?php publicatePhone(); ?>";
alert(x);
return false;
}else{
alert('not checked');
}
}
** The file functions.php:
<?php function publicatePhone(){
$con=mysql_connect("localhost","root","hihi51978");
mysql_select_db("script_database2");
//$publicate = "INSERT INTO phone (phone_number, publicate_number) VALUES
('212661132084', 'yes')";
$publicate = "UPDATE phone SET publicate_number = 'yes' WHERE
phone_number='212661132084'";
$publicate_result = mysql_query($publicate);
if ($publicate_result==true){echo 'request executed successfelly';}
else {echo 'request not executed';}
}
?>
**The form:
<div id="answer1"style="margin: 20%;">
Show my phone number on website's result:
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post" />
<p><label name="labelyes" style="background-color: #035d54; padding: 6px
30px 6px 30px; border-radius: 35px;" onclick="Javascript:answer1yes()" >
<input style="display: none;" type="radio" id="answer1oui" name="question1"
value="yes">Yes</label><p>
</form>
</div>
The code show "request executed successfelly" but the request not updating my phone table