0

I am making a project about a webpage where you can sign in and after that login.

I started trying to make a form that save user's information, you know, something simple, I made the database, the connection using php, the server's user and password and all those things, and it doesn't work! I tried everything (I think) and it didn't work, also showing me the classic "Error 500".

I want to share my PHP code with so you can see what's my problem:

<?php

//Connecting with server

$conexion = mysql_connect('localhost', '<username>', '<password>');

//verificar conexi贸n

if(!$conexion){

    echo"No se conect贸 con servidor.";
}else {

    $conexiondb = mysql_select_db('hermanos_Hashem');

    if(!$conexiondb){ 

        echo"No se conect贸 con base de datos.";


    }
}
// information

$user = $_POST['user'];
$correo = $_POST['correo'];
$pass = $_POST['pass'];
$tel = $_POST['tel'];
$genero = $_POST['genero'];
$pais = $_POST['pais'];
$fav = $_POST['fav'];
$sobremi = $_POST['sobremi'];

//saving

$guardar = "INSERT INTO usuarios VALUES(                
    '$user',
    '$correo',
    '$pass',
    '$tel',
    '$genero',
    '$pais',
    '$fav',
    '$sobremi'
    )";

$ejecutar = mysql_query($guardar);

if(!$ejecutar){

    echo"Error al llenar formulario.";   
}
else { 

    echo"datos guardados correctamente. <a href="www.google.com"> Volver </a>  " ;   
}  
?>
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Where did you run code : localhost or in any domain ? – Abhishek Kamal Jan 18 '20 at 05:43
  • `if (!$conexion) { die('Could not connect: ' . mysql_error()); }` _put the code after `//verificar conexi贸n` in your's code and then update here about what it prints_ – Abhishek Kamal Jan 18 '20 at 05:54
  • Hello, thanks for your help, I run with the code you told me but i get same error, and I trying to run php in a domain in cpanel. – Edward Melenciano Jan 18 '20 at 14:14
  • You run php through a domain then check the username from c-panel for the database because some domain adds their unique string just before your username. Eg: if your username is `ciano` then the username according to c-panel may be `unique_string_ciano`. – Abhishek Kamal Jan 19 '20 at 01:28
  • Thanks for your comments guys!, I fixed it just changing mysql to mysqli and it works! – Edward Melenciano Jan 19 '20 at 03:09

0 Answers0