I have created user registration form and pass that values to class successfully. I want to know how to save that data using jquery ajax. but I don't know the way to call php class via jquery ajax. my code is this:
<?php
if(isset($_POST['register'])){
$register = new Users();
$msg = $register->registration($_POST['fullname'], $_POST['email'], $_POST['phone'], $_POST['password'], $_FILES);
}
?>
<h3> Registration </h3>
<?php
if(isset($msg)){
echo $msg;
}
?>
<form action="" method="post" enctype="multipart/form-data">
<p> Full name: <input type="text" name="fullname"/> </p>
<p> Email: <input type="email" name="email"/> </p>
<p> Phone: <input type="phone" name="phone"/> </p>
<p> Password: <input type="password" name="password"/> </p>
<p> Photo 1: <input type="file" name="photo[]"/> </p>
<p> Photo 2: <input type="file" name="photo[]"/> </p>
<p> <input type="submit" name="register" value="Register"/> </p>
</form>
Please someone help me to save this form using jquery ajax.
You will probable want something like this:
Without a PHP framework, here are some ways to do it:
1 - Put the function in its own file.
2 - Put a wrapper function in its own file: all it does is #require your file, then call your desired function.
3 - Create one file that handles ajax (that'll be the entry point). Then pass a choice of functions using GET. Something like ajax_handler.php?fn=MyFunction