PHP data does not go to database

Unless im being stupid i’ve tripled checked everything and its all correct. No error codes but I get no data to my table named ‘login’.

processing.php

<?php
$id = $_REQUEST['id'];
$pass = $_REQUEST['pass'];

// Connect to database
    $conn = mysqli_connect('sql213.epizy.com', 'epiz_25634201', 'HIDDEN BY MOD', 'epiz_25634201_logging');

// Check connection
if(!$conn){
echo 'Connection error:' . mysqli_connect_error();
}
//Insert details
$query = "INSERT INTO login(id,pass) VALUES('$id','$pass')";
    $result = mysqli_query($connection, $query);
    if(!$result){
        die("Fail".mysqli_error($connection))




//close connection
mysqli_close($conn);
?>

And then heres html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>The Photo Shop</title>

<link rel="stylesheet" href="main.css" type="text/css" />

<!--[if IE]>
  <script src="http://www.html5shiv.googlecode.com/svn/trunk/
html5.js"></script><![endif]-->
<!--[if lte IE 7]>
  <script src="js/IE8.js" type="text/javascript"></script><!
[endif]-->
<!--[if lt IE 7]>

  <link rel="stylesheet" type="text/css" media="all"
href="css/ie6.css"/><![endif]-->
</head>


  <h1 id="heading" class="body">The Picture Shop!</h1>
  <h2 id="heading" class="body">All Your Photos At Your Fingertips!</h2>
  <form id="login" method="POST" action="processing.php">
Username:<input type="text" name="id">
Password:<input type="password" name="pass">
         <input type="submit" name="submit">
  </form>

No need to be super prompt with replies

You can enable display errors from cpanel->Alter Php config in order to see the actual error.

2 Likes

Tried that, does nothing. No code.

Your code also has some security bugs (putting raw password into database And Mysql injection)
I tried to fix it with the knowledge i’ve.

<?php

// Connect to database
    $conn = mysqli_connect('sql213.epizy.com', 'epiz_25634201', 'HIDDEN BY MOD', 'epiz_25634201_logging');

// Check connection
if(!$conn){
echo 'Connection error:' . mysqli_connect_error();
}
$id = mysqli_real_escape($conn,$_POST['id']);
$pass = password_hash($_POST['pass'], PASSWORD_DEFAULT);
//Insert details
$query = "INSERT INTO login(id,pass) VALUES('$id','$pass')";
    //$result = mysqli_query($connection, $query); <- Found it! it's an undefined variable
      $result = mysqli_query($conn, $query);
    if(!$result){
        die("Fail".mysqli_error($connection))




//close connection
mysqli_close($conn);
?>
2 Likes

Also, replace HIDDEN BY MOD on the password section of the code @anon19508339 posted (I hid it for security reasons) to your hosting account password.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.