Past methods: Obsolescence alert and caution

Trying to grasp the concepts of PHP & MYSQL, I have written this code which seems to be functioning properly. However, there are several "warnings" that I am unsure about. Nonetheless, PHP successfully connects to the database. Below are the relevant codes:

myPage.php is considered the main page.

<!DOCTYPE HTML>
<html>
<head>
    <link rel="stylesheet" href='http://localhost/prove/librerie/bootstrap/css/bootstrap.css'></script>
    <script type="text/javascript" src='http://localhost/prove/librerie/angular.min.js'></script>
    <script type="text/javascript" src='http://localhost/prove/librerie/bootstrap/js/bootstrap.min.js'></script>
<body>
    <form action="procces.php" method="POST">
        <div class="text-info identazione" class="identazione">Username : </div><input lass="form-control" type="text" name="username"/>
        <div class="text-info identazione">Password : </div><input type="text" name="password"/>
        <div class="identazione"><input class=" btn btn-success" type="submit"/></div>
    </form>
</body>
</head>

<style>
    body {
        padding : 50px;
    }   
    .identazione{
        padding: 12px;
    }

</style>

process.php

    <?php 
//from myPage to local variables
    $username = $_POST['username'];
    $password = $_POST['password'];
//to prevent mysql injection
    $username= stripcslashes($username);
    $password= stripcslashes($password);
    $username= mysql_real_escape_string($username);
    $password= mysql_real_escape_string($password);
//connection to server and selection of database
    mysql_connect("localhost","root","");
    mysql_select_db("login");
//query to database for user
    $risultato= mysql_query("select * from utenti where username = '$username' and password = '$password' ") or die("User not found, please check your credentials".mysql_error());
    $row = mysql_fetch_array($result);
    if($row['username']==$username && $row['password']==$password){
        echo "Login Successful. Welcome".$row['username'];
    }
    else
        echo "Incorrect Login. Please re-enter your details";

?>

Below is a screenshot showing the warnings:

https://i.stack.imgur.com/5yIhp.png

Additionally, I work on Chrome and use Wampp. The comments in Italian should not pose an issue. I have created a database named login, defined with fields for username, password, and id. I have also set up a test user with the credentials usertest and userpass. These login details work when entered, despite the presence of errors.

UPDATE:

I corrected 'result' to 'risutato', which was my mistake resulting in only two warnings now. However, it appears I need to update my knowledge as I am utilizing outdated sources.

https://i.stack.imgur.com/lLEgb.png

Answer ā„–1

Before proceeding any further, it is important to note that outdated methods are being used and some research should be done before progressing.

Using mysql is no longer supported and poses risks such as injection attacks. It is recommended to read up on how to execute database queries properly using tools like PDO -

An alternative to consider is mysqli, but PDO is highly recommended.

In addition, it is crucial to address security concerns such as storing passwords in plain text, which is unsafe. For better security measures, I suggest looking into this resource - http://php.net/manual/en/function.password-hash.php

This will guide you on utilizing functions like password_hash() and password_verify().

I hope this information proves helpful.

Answer ā„–2

For the sake of security, it is highly advised to avoid using mysql_connect!

It is recommended to switch over to either mysqli or pdo.

If you want to hide or suppress deprecated warnings, you can add this code snippet at the top of your page:

error_reporting(E_ALL ^ E_DEPRECATED);
error_reporting(0);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The issue of unselection not functioning properly for multiple items when using both selectable and draggable features

i need the unselection of list items to be as smooth as selectable() but without draggable() My desired outcome is similar to the following gif showcasing combined selectable and draggable functionality: https://i.stack.imgur.com/3GjTD.gif here's t ...

Customize your error messages in AJAX requests

The form on my index.php page submits to process.php, triggering the execution of the code below: $(document).ready(function() { $('#login_button').click(function() { event.preventDefault(); var formData = { 'email' ...

Toggle display of divID using Javascript - Conceal when new heading is unveiled

At the moment, I have implemented a feature where clicking on a title reveals its corresponding information. If another title is clicked, it opens either above or below the previously opened title. And if a title is clicked again, it becomes hidden. But ...

Position Font Awesome to the right of the text in the list

Hi there, I am currently working on a project where I want to align font awesome icons to the right of my text within a list. My website is in a Right-to-Left (RTL) language and I can't seem to find any resources on how to achieve this. Any help would ...

Utilizing AJAX to retrieve and process JSON information

Hey there! I've been diving into the world of creating AJAX calls to PHP scripts lately. Trying to figure out the best solution to handle these AJAX calls, you can check out my client-side code in this question. I'm here to validate my underst ...

Identify an asynchronous JavaScript and XML (AJAX)

As a part of my practice, I am developing my own MVC framework and have created a Request class. My goal is to identify the type of request being made, whether it is an AJAX/JSON call or an HTML/XML request, in order to parse the data accordingly. Current ...

Splitting HTML content into nodes using PHP XPath (including empty nodes)

I am currently attempting to separate the HTML string into individual nodes, along with their text content if applicable. Here is the HTML string that I am working with: <p>Paragraph one.</p> <p><strong>Paragraph <em>two</ ...

delete specific elements from an associative array

I am working with two arrays: $pool = array( 'foo' => array('foobar1'), 'bar' => array('foobar2'), 'lou' => array('foobar3'), 'zuu' => array('foobar ...

Using CKEditor in an AngularJS web application: Tips and tricks

I'm having trouble integrating the ckeditor into an HTML page that's built with angularjs. Despite trying out numerous examples, such as the ng-ckeditor and ckeditor directives, I haven't found a solution that works for me. What I need is ...

Attention! Are you aware of the potential consequences of the impending phase-out of the name attribute in W3C validation? Have you considered how this development

Any thoughts on what could replace the name attribute? According to the W3C validator... Validation Output: 4 Warnings Here is a list of the warning message(s) generated while checking your document. Warning Line 12, Column 21: The name attribute i ...

In the iOS app when the Ionic HTML5 select keypad is opened, a bug causes the view to scroll upwards and create empty space after tapping the tab

I am currently working with Ionic v1 and AngularJS, utilizing ion tabs: <ion-tabs class="tabs-icon-top tabs-color-active-positive"> <!-- Home Tab --> <ion-tab icon-off="ion-home" icon-on="ion-home" href="#/tab/home"> <ion-nav ...

Adjust the width of the dropdown menu to match the text input field using jQuery

Struggling with jquery-mobile to collect user information, I am facing an issue aligning the width of my select menu with the text input fields. Despite successfully matching the background and border colors of the select menu with the text input fields, ...

I am looking for a way to create a fixed bottom navbar that evenly spreads out the links across the entire width of the screen. It should also be responsive

:) I'm experimenting with my fixed bottom navbar in bootstrap.. It's working to some extent.. But unfortunately, the links in my navbar won't justify.. I've tried everything I can think of.. I want it to be responsive so the current ...

After performing a URL rewrite, the Yii Ajax save operation returns a 301 response

I've implemented an inline editor that utilizes AJAX to save content by calling a Yii controller. The process works perfectly fine. However, after shortening my URLs using .htaccess and Yii urlManager, I encountered a 301 response when trying to save ...

Unable to retrieve DOM value due to Vue.js template being inaccessible in Chromium, including from both DevTools and extensions

Currently, Iā€™m developing a Chrome extension that needs to retrieve specific values from a webpage such as the item title. However, instead of fetching the actual title, it is reading a Vue.js template variable. Even when I use DevTools to inspect the p ...

I am experiencing issues with CSS functionality in my Ruby on Rails application

Currently, I am in the process of creating a blog based on Mackenzie Child's 12 in 12 RoR tutorials. I diligently followed all the steps in the tutorial and adhered strictly to his code. However, I encountered an issue with the CSS stylesheets not be ...

Selecting data from a many-to-many relationship in MySQL involves

I'm currently working on creating a MySQL Many to Many select query. In my database, I have three tables: Profiles Skills Profile_skills (Profile ID and Skills ID) My goal is to search for a specific skill (such as PHP) and retrieve a list of all ...

Loading a specific CSS file along with an HTML document

Creating a responsive website, I'm looking to incorporate a feature that allows for switching between a mobile version and a standard desktop version similar to what Wikipedia does. To achieve this, I would need to reload the current HTML file but en ...

CSS: Handling Background Images Responsively

I'm experiencing an unusual issue where the image is not appearing, even though the div box shows up when I highlight elements on the page. Validation and inspection also show no issues. Here is the code: <div class="mainImage"></div> A ...

PHP unable to display HTML form element using its designated ID attribute

I've been experiencing some difficulties with PHP echoing a label element that contains an ID attribute within an HTML form. My intention was to utilize the ID attribute in order to avoid having to modify the JS code to use the name attribute instead. ...