Question: I am having problems when registering, to input values into members table. I have created values in databse for alll values. just can seem to

I am having problems when registering, to input values into members table. I have created values in databse for alll values. just can seem to see who registered or who logged in

Register

Registration Form

****************************************************************************************

have replaced values with stars...

db.php

//sql connection variables

$db_host = "**********";

$db_username = "*******"; // Database username

$db_password = "********"; // Database password

$db_data = "************"; // Database here

$db= mysqli_connect ($db_host, $db_username, $db_password, $db_data)

or die ('I cannot connect to the database. ');

?>

***********************************

CheckRegistration&login.php

require('db.php');

// If form submitted, insert values into the database. if (isset($_REQUEST['username'])){ // removes backslashes $username = stripslashes($_REQUEST['username']); //escapes special characters in a string $username = mysqli_real_escape_string($db,$username); $password = stripslashes($_REQUEST['password']); $password = mysqli_real_escape_string($db,$password); $phone = stripslashes($_REQUEST['phone']); $phone = mysqli_real_escape_string($db,$phone); $address = stripslashes($_REQUEST['address']); $address = mysqli_real_escape_string($db,$address); $email = stripslashes($_REQUEST['email']); $email = mysqli_real_escape_string($db,$email); $education = stripslashes($_REQUEST['education']); $education = mysqli_real_escape_string($db,$education); $query = "INSERT into `users` (username, password, phone, address, state, email, education) VALUES ('$username', '".md5($password)."' '$phone','$address','$email','$education')"; $result = mysqli_query($db,$query); if($result){ echo "

You are registered successfully.

Click here to Login

";

}

header('location: members.php'); // redirect after registering to homepage

}

require('db.php');

if(isset($_POST['username'])){ $username = stripslashes($_REQUEST['username']); $username = mysqli_real_escape_string($db, $username); $password = stripslashes($_REQUEST['password']); $password = mysqli_real_escape_string($db, $password); $query = "SELECT * FROM milestone3users WHERE username='$username' AND password='".md5($password)."'"; $result = mysqli_query($db,$query) or die(mysql_error()); $results = mysqli_num_rows($result); if($results==1){ $_SESSION['username'] = $username; $_SESSION['id'] = $id; // Redirect user to index.php header("Location: members.php"); } else { echo "

You did not enter correct username/password

Click here to Login"; } } ?>

*******************************

members.php

!DOCTYPE html>

Members Page

ID Phone Email Address Education

require_once('db.php');

$db_host = ('localhost');

if(isset($_POST['update']))

{

$id=$_POST['id'];

$phone = $_POST['phone'];

$address = $_POST['address'];

$email = $_POST['email'];

$education = $_POST['education'];

$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. " Education : ".$education;

}

}

?>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!