Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?php	

include 'db_connection.php';


$fname = $_REQUEST['fname'];


$Lname = $_REQUEST['Lname'];


$Mname=$_REQUEST['Mname'];

$fathername= $_REQUEST['fathername'];


$address= $_REQUEST['address'];

$gender= $_REQUEST['gender'];

$city =$_REQUEST['city'];

$state =$_REQUEST['state'];

$dob =$_REQUEST['dob'];

$phone = $_REQUEST['fphone'];

$pin = $_REQUEST['pin'];

$email =$_REQUEST['email'];

$password =$_REQUEST['password'];

$sql ="INSERT INTO  form (first_name, last_name, mother_name, father_name, address_detail, gender, city, state , dob, phone_number, pin, email_id, password) VALUES ('".$fname."', '".$Lname."', '".$Mname."', '".$fathername."', '".$address."', '".$gender."', '".$city."', '".$state."', '".$dob."', '".$phone."', '".$pin."', '".$email."', '".$password."' )";

if ($conn->query ($sql) == TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
	
	
?>


What I have tried:

I don't know this error with email variable all columns and data is set but email......
Posted
Updated 10-Nov-22 21:53pm
Comments
Member 15627495 11-Nov-22 3:52am    
the name in your html tag email form is not the same in the $_request array.
it's a 'naming' error. read again your html form, and copy paste the email good name.

when the error is 'undefined' in an array, look at the spelling name of your var in the array.
Rebics Copy 11-Nov-22 3:54am    
Email
 <input type="password" name="password" class="form-control form-control-lg" required/>

this is the code in index.php

1 solution

As I said last time: Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.

When you concatenate strings, you cause problems because SQL receives commands like:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'
The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;--'
Which SQL sees as three separate commands:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';
A perfectly valid SELECT
SQL
DROP TABLE MyTable;
A perfectly valid "delete the table" command
SQL
--'
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.

So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?

If you aren't going to listen when you are told important things, id there any point in asking a question at all?

And never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^]

And remember: if you have any European Union users then GDPR applies and that means you need to handle passwords as sensitive data and store them in a safe and secure manner. Text is neither of those and the fines can be .... um ... outstanding. In December 2018 a German company received a relatively low fine of €20,000 for just that.
 
Share this answer
 
Comments
Rebics Copy 11-Nov-22 4:00am    
Bro I am just learning and at this time i just want data in phpmyadmin that's it.
the error is undefined array key "email".
 <input type="password" name="password" class="form-control form-control-lg" required/>

and this is the code please let drag out me from this. frustated
OriginalGriff 11-Nov-22 4:06am    
Then learn properly.
Don't ignore serious flaws when they are pointed out: fixing them throughout your app may even help fix your problems without you knowing about them.

Leaving them unfixed puts your whole DB (and financial stability) at risk - and learning bad habits to start with is a recipe for real failures later.
Member 15627495 11-Nov-22 4:04am    
first lines of code to write are hard work, that's true.
in your job, you'll encount lot of tiny bug fix like you do today.
It's common and usual error. don't worry. you'll grow in skills every day.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900