0

unified index

i fined problem while i execute this code $servername = "localhost"; $username = "username"; $password = ""; $dbname="test_sup"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }else{ $email=$_POST['email']; $query="SELECT * FROM `sign_up` WHERE email='$email' AND password='$password'"; $res=$conn->query($query); if($row=$res->fetch_assoc()) { echo'logine successfuly'; } else{ echo'password or email isnt correct'; }

9th Oct 2018, 9:16 PM
Ossama Achki
Ossama Achki - avatar
2 Respostas
+ 1
undefined index error usually is triggered by an attempt to access an element of an array where the element referred to by index or key doesn't exist. I suspect it was happening when you tried to assign $_POST['email'] to $email variable, please check if there is an element in $_POST having 'email' as its key, you can do: print_r($_POST); To see if such element exists or not. I also noticed your query includes the $password variable that you used to connect to the localhost (which is blank), I just want to remind you whether it was intentional. P.S. Will you move that error message out of "Relevant tags" and into "Description" please? it's confusing. Hth, cmiiw
10th Oct 2018, 1:12 PM
Ipang
0
you probably not sending the email as a post, you can make a html form in another file set the method to post then create an input field name 'email' and submit button. so you can run the php code from that file
10th Oct 2018, 12:06 PM
Taste
Taste - avatar