$ _POST does not get all values

My $ _POST gets the username and password, but not any other conditions that I have. All names correspond to what I have in my table. I have to miss something. First, my HTML file with the form data, and the second is the php file, which should store 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' ) ; ?> 
+4
source share
2 answers

Your HTML attributes are not formatted correctly.

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

Two working formats are formatted correctly, while others are not.

For example, <input type:"text" name"email"> is incorrect. 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 are not using one of them yet, I would suggest you get a code editor with syntax highlighting or auto-complete. Notepad ++, Netbeans, or Visual Studio can color your code and make troubleshooting easier.

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

+6
source

There are a few errors in your markup:

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

it should be

 <input type="text" name="" /> 
+2
source

Source: https://habr.com/ru/post/1448055/


All Articles