I've created a PHP function which is hosted on a web server. The code here is designed to allow the user to create a user account which requires their forename, surname, email and password. I can use Apigee to submit the data, so I know that everything works. A snapshot of my code is below:
function student2_post() {
$this->load->database();
$StudentID = $_POST['StudentID'];
$StudentForename = $_POST['StudentForename'];
$StudentSurname = $_POST['StudentSurname'];
$StudentEmail = $_POST['StudentEmail'];
$StudentPassword = $_POST['StudentPassword'];
$info = array('StudentID'=>null, 'StudentForename'=>$StudentForename, 'StudentSurname'=>$StudentSurname, 'StudentEmail'=>$StudentEmail, 'StudentPassword'=>$StudentPassword);
$this->db->insert('StudentLogin', $info);
$data->StudentID = $StudentID;
$data->StudentForename = $StudentForename;
$data->StudentSurname = $StudentSurname;
$data->StudentEmail = $StudentEmail;
$data->StudentPassword = $StudentPassword;
$this->response($data, 200);
}
My next step of development is to try and develop an "app" or a mobile service which allows me to use my own GUI. My code for this is below:
<!-- Home -->
<div id="page2" class="ui-bar-a" data-role="page">
<div data-role="header" data-theme="320CT_Coursework.min">
<h3>
320CT
</h3>
</div>
<div data-role="content">
<div data-role="fieldcontain" id="StudentID">
<fieldset data-role="controlgroup">
<label for="StudentID">
Name
</label>
<input name="" id="StudentID" placeholder="" value="" type="text">
</fieldset>
</div>
<div data-role="fieldcontain" id="StudentForename">
<fieldset data-role="controlgroup">
<label for="StudentForename">
Surname
</label>
<input name="" id="StudentForename" placeholder="" value="" type="text">
</fieldset>
</div>
<div data-role="fieldcontain" id="StudentSurname">
<fieldset data-role="controlgroup">
<label for="StudentSurname">
Email
</label>
<input name="" id="StudentSurname" placeholder="" value="" type="text">
</fieldset>
</div>
<div data-role="fieldcontain" id="StudentPassword">
<fieldset data-role="controlgroup">
<label for="StudentPassword">
Password
</label>
<input name="" id="StudentPassword" placeholder="" value="" type="text">
</fieldset>
</div>
<input type="submit" value="Submit">
</div>
<div data-role="footer" data-theme="a" data-position="fixed">
<h3>
</h3>
</div>
</div>
This works and brings up a GUI for me to enter data in, however obviously it doesn't link up. I've got all the form elements there I need, with IDs which is kosher to the PHP function.
I've been unable to find any resources which allow me to use the PHP function *student2_POST* in my jQuery code. Everything I find seems to be related to non-PHP functions.
TLDR: I have a function hosted on a web service which submits a form and I need a way to implement this function in jQuery. Thank you in advance for your help!
In order to communicate between client (html / js) and server (php), you need to execute an HTTP request.
This may tipycally be done using an HTML form
, or dynamically using AJAX methods such as (for JQuery) :