there is mi php code and there is my blocks. i dont know why i get this message undefined array key "boton" in /storage/ssd3/292/21963292/....
// 1.- IDENTIFICACION nombre de la base, del usuario, clave y servidor
// 2.- CONEXION A LA BASE DE DATOS
include_once "pruebaconexionwebhost.php"; // Incluir el archivo con la conexión a la base de datos
$boton = $_POST['boton'];
/////////////////////////////// INSERTAR - INSERT ////////////////////////////////////
if ($boton == "btnInsertar"){
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$query="INSERT INTO clientes (nombre, email, telefono) VALUES ('$nombre','$email','$telefono')";
$result = mysqli_query($link, $query);
print("Datos agregados a la base.");
mysqli_close($link);
}
i am using am example to send data to mysql hosting and there are my blocks
<?php
// Datos de conexión a la base de datos
$servername = "localhost"; // Cambia esto si es necesario
$username = "id21963292_nickolae";
$password = "JUEGOS1990()q";
$dbname = "id21963292_testeo";
// Intentar conectar a la base de datos
$link = new mysqli($servername, $username, $password, $dbname);
// Verificar la conexión
if ($link->connect_error) {
die("La conexión falló: " . $link->connect_error);
} else {
echo "Conexión exitosa a la base de datos!";
}
// Cerrar la conexión
$link->close();
?>
and the other full code is
<?php
// Juan Antonio Villalpando
// juana1991@yahoo.com
// http://kio4.com
// https://kio4.000webhostapp.com/mysqli_post.php
// 1.- IDENTIFICACION nombre de la base, del usuario, clave y servidor
// 2.- CONEXION A LA BASE DE DATOS
include_once "pruebaconexionwebhost.php"; // Incluir el archivo con la conexión a la base de datos
$boton = $_POST['boton'];
/////////////////////////////// INSERTAR - INSERT ////////////////////////////////////
if ($boton == "btnInsertar"){
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$query="INSERT INTO clientes (nombre, email, telefono) VALUES ('$nombre','$email','$telefono')";
$result = mysqli_query($link, $query);
print("Datos agregados a la base.");
mysqli_close($link);
}
/////////////////////////////// BORRAR - DELETE ////////////////////////////////////
if ($boton == "btnBorrar"){
$Nombre = $_POST['nombre'];
$query="delete from clientes where nombre='$nombre'";
$result = mysqli_query($link, $query);
print("Datos borrados.");
mysqli_close($link);
}
////////////////////////////// ACTUALIZAR - UPDATE ///////////////////////////////
if ($boton == "btnActualizar"){
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$query="update personas set email='$email', telefono='$telefono' WHERE nombre='$nombre'";
$result = mysqli_query($link, $query);
print("Datos modificados.");
mysqli_close($link);
}
///////////////////// BUSCAR POR NOMBRE - SEARCH BY NAME /////////////////////////////
if ($boton == "btnBuscarNombre"){
$nombre=$_POST['nombre'];
$hacer = mysqli_query ($link, "SELECT * FROM clientes WHERE nombre='$nombre' ");
enviar_respuesta($hacer);
}
/////////////////////// MOSTRAR TABLA - SHOW TABLE /////////////////////////////////////
if ($boton == "btnVerTabla"){
$hacer = mysqli_query ($link, "SELECT * FROM clientes");
enviar_respuesta($hacer);
}
/////////////////////// OBTENER ORDENADO - GET SORT /////////////////////////////////////
if ($boton == "btnOrdenar"){
$Columna = $_POST['Columna'];
$hacer = mysqli_query ($link, "SELECT * FROM clientes ORDER BY $Columna ASC");
enviar_respuesta($hacer);
}
////////////////////////////// RESPUESTA - RESPONSE ///////////////////////
// En los casos que hay btnBuscarNombre o btnVerTabla y se debe enviar una respuesta actúa este código.
function enviar_respuesta($hacer)
{
$resultado = mysqli_query($GLOBALS['link'], "SHOW COLUMNS FROM clientes");
$numerodefilas = mysqli_num_rows($resultado);
if ($numerodefilas > 0) {
$en_csv='';
while ($rowr = mysqli_fetch_row($hacer)) {
for ($j=0;$j<$numerodefilas;$j++) {
$en_csv .= $rowr[$j].", ";
}
$en_csv .= "\n";
}
}
print $en_csv;
}
///////////////////////////////////////////////////////////////////
?>
<?php // Datos de conexión a la base de datos $servername = "localhost"; // Cambia esto si es necesario $username = "id21963292_nickolae"; $password = "JUEGOS1990()q"; $dbname = "id21963292_testeo"; // Intentar conectar a la base de datos $link = new mysqli($servername, $username, $password, $dbname); // Verificar la conexión if ($link->connect_error) { die("La conexión falló: " . $link->connect_error); } else {
echo "Conexión exitosa a la base de datos!";
} // Cerrar la conexión $link->close(); ?>
Can you provide the link to the topic where Juan's original php is located?
What are you expecting this code to do with your three items of data ?
(Note: it would help if you provided formatted (pretty print) php)
With that "replace" block you want to replace the blanks, by %20. Then you need to have a blank in "segment" (now you have an empty string...which is not the same). Put a space in the "segment" string.