<?php
if($_REQUEST)
{
$uname = $_REQUEST["set_username"];
$email = $_REQUEST["set_email"];
$pword = $_REQUEST["set_password"];
if (isset($_POST['submit1']))
{
include 'db_connect.php';
$USERNAME=$_REQUEST["username"];
$PASSWORD=$_REQUEST["password"];
$results = $conn->query("SELECT * FROM strea345_db1 where username='$USERNAME' AND password='$PASSWORD'");
if($row = $results->fetch_assoc())
{
session_start();
$id=$row['username'];
$_SESSION["username"] = $id;
//echo $id;
header("Location: welcome.php");
}
else
{
header("Location: error1.php");
}
// Frees the memory associated with a result
$results->free();
}
if($email && $pword)
{
include 'db_connect.php';
$query = "SELECT * FROM strea345_db1 WHERE username ='$uname' || username ='$uname' && email ='$email' ||email ='$email' ";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) == 0)
{
$stmt = $conn->prepare("INSERT INTO strea345_db1 (username, password, email) VALUES (?, ?, ?)");
//$password = md5($password);
$stmt->bind_param('sss', $uname,$pword,$email);
/* execute prepared statement */
$stmt->execute();
if ($stmt->error) {error_log("Error: " . $stmt->error); }
$success = $stmt->affected_rows;
/* close statement and connection */
$stmt->close();
/* close connection */
$conn->close();
error_log("Success: $success");
if ($success > 0) {
error_log("User '$email' created.");
header("Location: index.html");
}
else {
echo '{"success":0,"error_message":"Email Exist."}';
}
}
else
{
header("Location: error.php");
}
}
else
{
echo '{"success":0,"error_message":"Invalid Email."}';
}
}
else
{
echo '{"success":0,"error_message":"Invalid Data"}';
}
?>
What looks like it needs fixed?