Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Cómo hacer que esta solicitud de AJAX (inicio de sesión) esté protegida

Estoy creando un sistema de inicio de sesión en mi sitio web, pero el navegador dice que no está protegido: el mensaje del navegador

Aquí está mi html:

 <div id="loginform"> Bejelentkezés <input type="text" placeholder="E-mail" id="email"></input> <input type="password" placeholder="Jelszó" id="password"></input> <button id="loginbutton">Bejelentkezés</button> <div id="errormsg"></div> </div>

Aquí está mi Ajax:

 $("#loginbutton").click(function(){ var user ={ email: $('#email').val(), password: $('#password').val() }; $.ajax({ url: 'login.php', type: 'POST', dataType: "json", data: {"user": JSON.stringify(user)}, success: function(data){ if(data.success){ alert(data.user_id); } else{ document.getElementById("errormsg").innerHTML = "A bejelentkezés sikertelen"; } } }); });

Y mi PHP:

 <?php session_start(); $conn = mysqli_connect("localhost", "root", "", "getpet"); $results = array( 'success' => false, 'user_id' => "azaz", 'fname' => "", 'lname' => "" ); if(isset($_POST['user'])){ $user = json_decode($_POST['user']); $email = $user->email; $password = md5($user->password); $sql= "SELECT * FROM users WHERE email = '".$email."' AND password = '".$password."'"; $rowsql = mysqli_query($conn, $sql); $row = mysqli_fetch_array($rowsql, MYSQLI_BOTH); if(mysqli_num_rows($rowsql) == "1"){ $_SESSION['user_id'] = $row['user_id']; $_SESSION['fname'] = $row['fname']; $_SESSION['lname'] = $row['lname']; $results['success'] = true; $results['user_id'] = $row['user_id']; $results['fname'] = $row['fname']; $results['lname'] = $row['lname']; } } else{ $results['user_id']= "VAnbaj"; } echo json_encode($results); ?>

Funciona, pero no sé cómo hacerlo seguro. Me alegraría si alguien me puede ayudar.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si desea deshacerse de ese mensaje de advertencia, debe servir su sitio a través de https con un certificado válido.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!