Jump to content

update php mysql using ajax


gongpex

Recommended Posts

Hello everyone,

 

I have a code :

 

index.php

<html><head></head><body><form action="update.php" method="post">   <label>Name</label>  <input type="text" name="test"  />  <select name="activate">    <option value="on">ON</option>    <option value="off">OFF</option>  </select><button>Update</button></form></body></html>

usually if we want to update we put this code :

 

update.php

<?php$test = $_POST['test'];$activate = $_POST['activate'];mysqli_query($connect,"update name_table set status='$activate' where name ='$test'")?>

Q : how to set ajax so that user no need to press submit button, but only choose 'ON / OFF' on select option so the update script (on update.php) can be executed?

 

please help me

 

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...