Hi guys I have a simple form that will allow users to sign up
<form name="signupform" id="signupform" onsubmit="return false;">
<div>Username: </div>
<input id="username" type="text" onblur="checkusername()" onkeyup="restrict('username')" maxlength="16">
<span id="unamestatus"></span>
<div>Email Address:</div>
<input id="email" type="text" onfocus="emptyElement('status')" onkeyup="restrict('email')" maxlength="88">
<div>Create Password:</div>
<input id="pass1" type="password" onfocus="emptyElement('status')" maxlength="16">
<div>Confirm Password:</div>
<input id="pass2" type="password" onfocus="emptyElement('status')" maxlength="16">
<div>Unique Company ID:</div>
<input id="companyID" type="number" onfocus="emptyElement('status')">
<div>Company Name:</div>
<input id="compname" type="text" onfocus="emptyElement('status')">
<button id="signupbtn" onclick="signup()">Create Account</button>
<span id="status"></span>
</form>
However, i'm getting a problem in that one of the form parts, the company name is not being commited to a variable, I know this because I check it with the following code in ajax.
if(u == "" || e == "" || p1 == "" || p2 == "" || c == "" || cid == "" || cn == ""){
status.innerHTML = "Fill out all of the form data";
now, the weird thing is I'm sure that I am saving the variables correctly. The form should call the following ajax function.
function signup(){
var u = _("username").value;
var e = _("email").value;
var p1 = _("pass1").value;
var p2 = _("pass2").value;
var cid = _("companyID").value;
var cn = _("compname").value;
var status = _("status");
and then it gets sent with
ajax.send("u="+u+"&e="+e+"&p="+p1+"&c="+c+"&cid="+cid+"&cn"+cn);
and in the php I have it so I assign it to variables in php
// GATHER THE POSTED DATA INTO LOCAL VARIABLES
$u = preg_replace('#[^a-z0-9]#i', '', $_POST['u']);
$e = mysqli_real_escape_string($db_conx, $_POST['e']);
$p = $_POST['p'];
$cid = preg_replace('#[^0-9]#', '', $_POST['cid']);
$cn = preg_replace('#[^a-z0-9.\- ]#', '', $_POST['cn']);
$c = preg_replace('#[^a-z ]#i', '', $_POST['c']);
but it keeps running into that else if, and even when I remove that, no data gets commited to the database for compname ($cn) ONLY, every other variable gets send and stored in the database except for $cn.
Was wondering if I've done something fundamentally wrong here, or its just i've missed something out?
Thanks in advance!
EDIT - changes question to deal with new issue that has arisen.
+"$cn"+cnshould be+"&cn"+cn. Although you probably should url encode your values as well.