Question
My registerform.php is not working, i also want user to be able to update phone,address,email, education... getting errors on members.php Notice : Undefined index: id
My registerform.php is not working, i also want user to be able to update phone,address,email, education...
getting errors on members.php
Notice: Undefined index: id in C:\xampp\htdocs\members.php Notice: Undefined index: phone in C:\xampp\htdocs\members.php Notice: Undefined index: address in C:\xampp\htdocs\members.php Notice: Undefined index: email in C:\xampp\htdocs\members.php Notice: Undefined index: education in C:\xampp\htdocs\members.php
registerform.php
--------------------------------
Registration Form
------------------------------
checkregistration.php
if (isset($_POST['signup'])) { // receive all input values from the form $username = mysqli_real_escape_string($db, $_POST['username']); $email = mysqli_real_escape_string($db, $_POST['email']); $password_1 = mysqli_real_escape_string($db, $_POST['password_1']); $password_2 = mysqli_real_escape_string($db, $_POST['password_2']); $address = mysqli_real_escape_string($db, $_POST['address']); $phone = mysqli_real_escape_string($db, $_POST['phone']); $education = mysqli_real_escape_string($db, $_POST['education']); // form validation: ensure that the form is correctly filled if (empty($username)) { array_push($errors, "Username is required"); } if (empty($password_1)) { array_push($errors, "Password is required"); } if ($password_1 != $password_2) { array_push($errors, "The two passwords do not match"); }
if (empty($email)) { array_push($errors, "Email is required"); } if (empty($phone)) { array_push($errors, "Phone is required"); } if (empty($address)) { array_push($errors, "Address is required"); } if (empty($education)) { array_push($errors, "Education is required"); } // register user if there are no errors in the form if (count($errors) == 0) { $password = md5($password_1);//encrypt the password before saving in the database $query = "INSERT INTO users (username, password, email, phone, address, education) VALUES('$username', '$password', '$email', '$phone', '$address', , '$education')"; mysqli_query($db, $query); $_SESSION['username'] = $username; $_SESSION['success'] = "You are now logged in";
}
header('location: members.php'); // redirect after registering to homepage
}
// Login user if (isset($_POST['login'])) { $username = mysqli_real_escape_string($db, $_POST['username']); $password = mysqli_real_escape_string($db, $_POST['password']); if (empty($username)) { array_push($errors, "Username is required"); } if (empty($password)) { array_push($errors, "Password is required"); } if (count($errors) == 0) { $password = md5($password); $query = "SELECT * FROM users WHERE username='$username' AND password='$password'"; $results = mysqli_query($db, $query); if (mysqli_num_rows($results) == 1) { $_SESSION['username'] = $username; $_SESSION['success'] = "You are now logged in"; header('location: members.php'); // direct to home page }else { array_push($errors, "Wrong username/password combination"); } echo("
"); // Added for line break. print_r($errors); // Will print all errors captured. }
}
?>
--------------------------------------
members.php
$id=$_POST['id']; $phone = $_POST['phone']; $address = $_POST['address']; $email = $_POST['email']; $education = $_POST['education'];
if(isset($_POST['update'])) { $sql = "update users SET phone='$phone', address='$address',email='$email',education='$education' where id=$id"; if (mysqli_query($db, $sql)) { { echo " Update is successful "; echo " Phone : ".$phone." Address :".$address." Email : ".$email; } } } ?>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started