This is probably obvious but cannot work out the isse
Form code
<form id="new_patient" method="post" action="process.php?opt=reg">
<h1>Create a New Patient Account</h1>
<span>Enter Patient details below, fields marked with "*" are required</span>
<div id="status"><br /></div>
<hr>
<fieldset>
<li>
<label for="fname">First Name: *</label>
<input type="text" name="fname" id="fname" placeholder="Enter your First Name" required autofocus size="50" maxlength="40" />
</li>
Okay straight forward, would expect the value entered to be in “fname”.
Submit button
<button type="submit" onClick="javascript:ajax_post();">Create Account</button>
Which is working and calling ajax_post.
js code
// Assign object properties
alert("okay doing js");
formdata.append("opt", "reg");
formdata.append("title", _("title").value);
formdata.append("fn", _("fname").value);
hr.open("POST", "process.php");
// So what was returned, error or not
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById("status").innerHTML = return_data;
}
}
// Send the data to PHP now ... and wait for response to update the status div
hr.send(formdata);
document.getElementById("status").innerHTML = "processing...";
Successfully calls process.php with post values, however a loop through $_POST indicates
`title: mr
fname: tim
( ! ) Notice: Undefined index: fn in C:\webpages\holistic\process.php on line 55``
I would have expected js to pass fn rather than fname ?!??!???!?!??!?!?!?