Sam Johnson
Sam Johnson

Reputation: 115

$_POST not receiving all values

My $_POST is receiving the username and password but not any of the other terms that I have. The names all match what I have in my table, I must be missing something..First is my HTML file with the form data and second is the php file which should be storing the values in my user_info table.

<HTML>
<link rel="stylesheet" href="testcss.css" type="text/css">
<body>

<div id="header">
<h1>Register</h1>
</div>

<div id="formtext">
    <form name="register" action="register.php" method="post">
    First Name: <input type:"text" name"firstName"><br>
    Last Name: <input type"text" name"lastName"><br>
    Email: <input type:"text" name"email"><br>
    Desired Username: <input type="text" name="username"><br>
    Password: <input type="text" name="password"><br>
    <input type="submit" name="Submit">
</div>

</body>
</HTML>

Here is the php file...

<?php
mysql_connect('localhost', 'root', 'root') or die(mysql_error());
mysql_select_db("myDatabase") or die(mysql_error());

$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$email = $_POST["email"];
$username = $_POST["username"];
$password = $_POST["password"];


mysql_query("INSERT INTO user_info(firstName, lastName, email, username, password) VALUES ('$firstName', '$lastName', '$email', '$username', '$password')");

header( 'Location: loaclhost:8888/userHome.html' ) ;

?>

Upvotes: 4

Views: 1192

Answers (2)

William Lawn Stewart
William Lawn Stewart

Reputation: 1205

Your HTML attributes aren't formatted correctly.

All attributes should be in the format attribute="value"

The two working ones are formatted correctly, while the others are not.

For example, <input type:"text" name"email"> is wrong. It should be <input type="text" name="email" />

They should be like this:

    First Name: <input type="text" name="firstName"><br>
    Last Name: <input type="text" name="lastName"><br>
    Email: <input type="text" name="email"><br>
    Desired Username: <input type="text" name="username"><br>
    Password: <input type="text" name="password"><br>
    <input type="submit" name="Submit">

If you aren't already using one, I would suggest you get a code editor that has syntax highlighting or autocomplete. Notepad++, Netbeans or Visual Studio can all colour your code and make it much easier to find mistakes.

You also have what is probably an error in your PHP: header( 'Location: loaclhost:8888/userHome.html' ) ; - I have a feeling that you were probably meaning to type "localhost" there ;-)

Upvotes: 7

Cyclonecode
Cyclonecode

Reputation: 30131

Your markup has a couple of errors:

<input type:"text" name="" />
<input type"text" name="" />

should be

<input type="text" name="" />

Upvotes: 3

Related Questions