Monday, 27 August 2018

The Php form does not publish all fields in MySql

I checked the answers under ( PHP Form not posting all fields 2 ) and I do have names in all form fields : .... However, It is only posting the id, the date, and the name... I am so confused.

Here is my Sign-up -html- :
<legend>Registration Form</legend><p></p>
<label> Name </label>
<input id="intext"  type="text" name="name" /><p></p>
<label> Email </label>
<input id="intext"  type="text" name="email" /><p></p>
<label> Zip_Code </label>
<input id="intext"  type="text" name="zipcode" /><p></p>
<label> UserName </label>
<input id="intext"  type="text" name="user" /><p></p>
<label> Password </label>
<input type="password" name="pass" /><p></p>
<label> Confirm Password </label>
<input type="password" name="cpass" /><p>&nbsp;</p>
<div class="center">Comments / Inquiry </div>
<div class="center">
<textarea id="textarea" name="comments" rows="10" cols="40"></textarea>

Here is my php function:
function NewUser() { $name = $_POST['name'];
$Name       = $_POST['name'];
$Email  = $_POST['email'];
$Zip_Code   = $_POST['zipcode'];
$UserName   = $_POST['user'];
$Password   = $_POST['pass'];
$Comments   = $_POST['comments'];
$query = "INSERT INTO WebsiteUsers (Name, Email, Zip_Code, UserName, Password, Comments)
VALUES  ('$name','$email','$zipcode','$user','$pass','$comments')";
$data = mysql_query ($query)or die(mysql_error());
if($data) { echo "Thank you for Registering with us.";
}
}
function SignUp() { if(!empty($_POST['user'])) //checking the 'user' name     which is from Sign-Up.html, is it empty or have some text
{
$query = mysql_query("SELECT * FROM WebsiteUsers WHERE UserName = '$_POST[user]' AND Password = '$_POST[pass]'") or die(mysql_error());
if(!$row = mysql_fetch_array($query) or die(mysql_error())) { newuser();
}


In your query are usign variables in lowercase but in variable declarations are with uppercase.
Can you try this code?
$query = "INSERT INTO WebsiteUsers (Name, Email, Zip_Code, UserName, Password, Comments)
VALUES  ('$Name','$Email','$Zipcode','$User','$Pass','$Comments')";

0 comments:

Post a Comment