This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I have 2 buttons on my table which delete and edit data from the table, (data from the database) the delete button works well but the edit isnt working.. It runs like it is working but when I list the data it is like I created in the PhpMyadmin..
here is the main edit code:
<?php
// Editar um registo de user
if (isset($_GET['editequip']) == False) {
// Caso seja chamado directamente na URL o ficheiro "editar.php",
// este é redireccionado para o ficheiro "lista.php"
header("location:javascript:history.go(-1);return false;;");
} else {
$editequip = trim($_GET['editequip']);
}
$connection = new mysqli('***', '****', '****', '****');
$obterequip = "SELECT * FROM fichas WHERE id_ficha LIKE '$editequip'";
$resultequip = $connection->query($obterequip);
// Se devolveu 0 ou mais do que um utilizador, termina script
if ($connection->affected_rows != 1) {
header("location:javascript:history.go(-1);return false;");
exit();
}
$objequip = $resultequip->fetch_object();
$id_ficha = $objequip->id_ficha;
$id_user = $objequip->id_user;
$avaria = $objequip->avaria;
$observacoes = $objequip->observacoes;
$observacoes_privadas = $objequip->observacoes_privadas;
$estado = $objequip->estado;
?> <!DOCTYPE HTML>
<html><head>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="favicon.ico" rel="shortcut icon">
<title>Edição de Equipamentos</title></head>
<body>
<div id="links">
Voltar ao site |
Ínicio |
Utilizadores |
Upload de Ficheiros |
Logout
</div>
<h1>Editar Estado</h1>
<div id="container"><div class="left">
<form action="updatequip.php" method="post" id="editar">
<input type="hidden" name="ificha" value="<?php echo $id_ficha ?>"/>
<label>ID da Ficha: </label> <?php echo $id_ficha ?> <br>
<label>ID do Cliente: </label><input type="text" name="iuser" value="<?php echo $id_user ?>"><br>
<label>Avaria: </label><input type="text" name="iavaria" value="<?php echo $avaria ?>"><br>
<label>Observações: </label><input type="text" name="iobservacoes"value="<?php echo $observacoes ?>"><br>
<label>Observações Privadas: </label><input type="text" name="iobservacoes_privadas" value="<?php echo $observacoes_privadas?>"><br>
<label>Estado</label><input type="text" name="iestado" value="<?php echo $estado ?>"><br>
<input type="submit" value="Alterar"/>
<input type="button" value="Cancelar"onclick="javascript:history.go(-1);return false;"/>
</form>
</div>
</div>
<div class="footer">
<p>Copyright © 2013 - Todos os direitos reservados - Númica</p>
</div>
</body>
</html>
and the action page:
<?php
// Inserir o registo na BD
include_once ('config1.php');
// Estabelecer a ligação à BD
$connection = new mysqli('*****', '*****', '*******', '***');
//Verificar se a ligação foi estabelecida com sucesso
if (mysqli_connect_errno() ) {
echo "</h2>Erro no acesso a BD</h2>" . mysqli_connect_error();
exit();
}
// Validar se os campos do formulário foram preenchidos pelo utilizador
// Verificar se "username" foi enviado
if (isset($_POST['ificha']) == FALSE) {
echo ("Erro de submissão no ida da ficha");
exit();
} else {
$id_ficha = trim($_POST['ificha']);
}
if (isset($_POST['iuser']) == FALSE) {
echo ("Erro de submissão do id do user");
exit();
} else {
$id_user = trim($_POST['iuser']);
}
if (isset($_POST['iavaria']) == FALSE) {
echo ("Erro de submissão da avaria");
exit();
} else {
$avaria = trim($_POST['iavaria']);
}
if (isset($_POST['iobservacoes']) == FALSE) {
echo ("Erro de submissão nas observacoes");
exit();
} else {
$observacoes = trim($_POST['iobservacoes']);
}
if (isset($_POST['iobservacoes_privadas']) == FALSE) {
echo ("Erro de submissão nas observacoesprivadas");
exit();
} else {
$observacoes_privadas = trim($_POST['iobservacoes_privadas']);
}
if (isset($_POST['iestado']) == FALSE) {
echo ("Erro de submissão no estado");
exit();
} else {
$estado = trim($_POST['iestado']);
}
// Final das validações (avisa caso algum erro seja detectado)
if ($erro) {
echo "<p>Formulário submetido com erros</p>";
echo $msgerro;
echo "<br>";
// Desenha 2 botões "Corrigir" e "Listar"
echo "<a class='ains' href='javascript:history.go(-1)' title='Volta à página anterior'>Corrigir </a>";
echo "<br/>";
echo "<a class='ains' href='verificarequipamentos.php'>Listar</a>";
exit();
}
$sql = "UPDATE fichas SET
id_user = '$id_user';
avaria = '$avaria';
observacoes = '$observacoes';
observacoes_privadas = '$observacoes_privadas';
estado = '$estado';
WHERE
id_ficha = '$id_ficha'";
$connection->query($sql);
// Lista users depois de actualizar
header("location:verificarequipamentos.php");
?>
Change the semicolons to comas on the update query Or concat the variables with dots, You shoud also use a framework for this kind of things, it could be much easier.
Related
I have a problem with my form, when I get in my website with Xampp, the webpage is not completed, doesn't appear the "region" combo box, the "fono" text field and the buttons, I don't know why it happens :( I wonder if someone could help me with this issue, please, as I fixed the bracket problems, now this problem is really freaking me out indeed.
<!DOCTYPE html>
<html>
<head>
<title>Formulario de datos</title>
<meta charset="UTF-8">
<script src="js/jquery.js"></script>
<script src="js/NumeroLetra.js"></script>
<script src="js/Hora.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/jquery.Rut.js"></script>
<script src="js/jquery.validate.js"></script>
</head>
<body onLoad="IniciarReloj24()">
<?php
ini_set('error_reporting',0);
include ('funciones.php');
?>
<form action = " " method="post">
<?php
//comprobamos el evento del boton
if ($_POST['btnRutBuscar'] == "Buscar"){
$cnn = Conectar();
//concatenamos los inputs para realizar el formato del rut
$rutt = $_POST['txtRut']."-".$_POST['txtDigito'];
//sentencia sql anidada entre registro y regiones
$sql = "select re.rut, re.nombres, re.apellidos, re.fnac, re.sexo, r.id, r.region, re.fono from registro re, regiones r where (re.region = r.id) and (re.rut = '$rutt')";
$rs = mysqli_query($cnn, $sql);
while ($row = mysqli_fetch_array($rs)){
$rut = $row['rut'];
$nom = $row['nombres'];
$ape = $row['apellidos'];
$fna = $row['fnac'];
$sex = $row['sexo'];
//recogemos el id de la tabla regiones que sera utilizada en el combo box de regiones
$id = $row['id'];
$reg = $row['region'];
$fon = $row['fono'];
//se les añade los value a los inputs para poder recibir los valores de la base de datos
}
}
?>
<center><h1>Formulario de datos: todo en uno</h1></center>
<center><h2>Creado por Matías Cáceres y Francisco Tello</h2></center>
<br>
<br>
<div align="center"><label>Rut:</label>
<input type="text" name="txtRut" id="txtRut" onkeypress="ValidaSoloNumeros()" value="<?php echo $rut?>" /> -
<input type="text" name="txtDigito" id="Verificador" size="2" onkeypress="ValidaSoloNumeros()" />
<input type="submit" name="btnRutBuscar" id="btnBuscar" value="Buscar" /></div>
<br>
<br>
<div align="center"><label>Nombres:</label>
<input type="text" name="txtNombres" id="txtNombres" onkeypress="txNombres()" value="<?php echo $nom ?>" />
<br>
<br>
<div align="center"> <label>Apellidos:</label>
<input type="text" name="txtApellidos" id="txtApellidos" onkeypress="txNombres()" value="<?php echo $ape ?>"/>
<br>
<br>
<div align="center"><label>Fecha de Naciemiento:</label>
<input type="date" name="txtFecha" value="<?php echo $fnac ?>" />
<br>
<br>
<div align="center"><label>Sexo:</label>
<select name="txtSexo">
<option value=""><?php $sex ?></option>
<option value = "Masculino">Masculino</option>
<option value = "Femenino">Femenino</option>
</select></div>
<br>
<br>
<div align="center"><label>Región:</label>
<?php
$cnn=Conectar();
$sql="select region from regiones";
$rs = mysqli_query($cnn,$sql); ?>
<select name="txtRegion">
<option value=""><?php echo $reg ?></option>
<?php while ($row=mysqli_fetch_array($rs))
{echo '<option>'.$row["region"];}
?>
</select>
</div>
<br>
<br>
<div align="center"><label>Fono:</label>
<input type="text" name="txtFono" id="txtFono" onkeypress="ValidaSoloNumeros()" value="<?php echo $fon ?>" />
</div>
<br>
<br>
<table>
<td><input type="submit" name="btnAgregar" id="btnAgregar" value="Agregar"/></div></td>
<td><input type="submit" name="btnModificar" id="btnModificar" value="Modificar"/></div></td>
<td><input type="submit" name="btnEliminar" id="btnEliminar" value="Eliminar"/></div></td>
<td><input type="submit" name="btnVerTodos" id="btnVerTodos" value="Ver Todos"/></div></td>
</table>
<?php
if($_POST['btnAgregar']=="Agregar")
{
$cnn = Conectar();
$rutt = $_POST['txtRut']."-".$_POST['txtDigito'];
$nom = $_POST['txtNombres'];
$ape = $_POST['txtApellidos'];
$fna = $_POST['txtFecha'];
$sexo = $_POST['txtSexo'];
$reg = $_POST['txtRegion'];
$fon = $_POST['txtFono'];
$sql = "insert into registro values('$rutt','$nom','$ape','$fna','$sexo','$reg','$fon')";
//este if lo acabo de colocar, es mas que nada para saber si ocurrio algo malo al momento de ejecutar la funcion (***** El if es necesario en todos los botones*****)
#Comprobar el nombre de las variables
if (empty($rut) || empty($nom) || empty($ape) || empty($fnac) || empty($sex) || empty($reg) || empty($fon)) {
echo "<script>alert('Todos los campos son obligatorios');</script>";
if( mysqli_query($cnn,$sql)){
echo "<script>alert('Se han grabado los datos')</script>";
echo "<script>window.location='index.php'</script>";
}else{
echo "<script>alert('ocurrio un problema');</script>";
}
}
}
if($_POST['btnEliminar']=="Eliminar")
{
$cnn = Conectar();
$rut = $_POST['txtRut']."-".$_POST['txtDigito'];//es necesario concadenar los dos inputs para que funcione la consulta
$sql = "delete from registro where (rut = '$rut')";
mysqli_query($cnn,$sql);
echo "<script>alert('Se eliminó el registro')</script>";
}
if($_POST['btnModificar']=="Modificar")
{
$cnn = Conectar();
$rutt = $_POST['txtRut']."-".$_POST['txtDigito']; //es necesario concadenar los dos inputs para que funcione la consulta
$nom = $_POST['txtNombres'];
$ape = $_POST['txtApellidos'];
$fna = $_POST['txtFecha'];
$sex = $_POST['txtSexo'];
$reg = $_POST['txtRegion'];
$fon = $_POST['txtFecha'];
$sql = "update registro set nombres='$nom', apellidos='$ape', fnac='$fna', sexo='$sex', region='$reg', fono='$fon' where rut='$rutt'";
mysqli_query($cnn,$sql);
echo "<script>alert('Se han editado los datos')</script>";
}
?>
</form>
<table border = '1'>
<tr>
<?php date_default_timezone_set('America/Santiago');
$vaFecha = date('d-m-y');
?>
<td>Fecha</td>
<td><input type = "text" name="caja_fecha" value = "<?php echo $vaFecha; ?>" disabled="disabled"></td>
</tr>
</table>
<form name="reloj24">
<input type="text" size="8" name="digitos" value=" " disabled="disabled">
</form>
<script>
$('#txtRut').Rut( {
digito_verificador: '#Verificador',
on_error: function(){ alert('Rut incorrecto');
$("#txtRut").val("");
$("#Verificador").val("");
}
} );
</script>
</body>
</html>
enter image description here
I'm working in a simple login screen with PHP and MySQL with this full code:
<?php
include("conexion.php");
session_start();
if (isset($_SESSION['username'])) {
?>
<!DOCTYPE html>
<meta charset="utf-8">
<html lang="es">
<html>
<head>
<title></title>
</head>
<body>
<h1>YA INICIASTE SESION <?php echo $_SESSION['username']?></h1>
</body>
</html>
<?php
}else{
?>
<!DOCTYPE html>
<html lang="es">
<meta charset="utf-8">
<head>
<title>Login</title>
<link rel="stylesheet" type="text/css" href="css/estilos.css">
</head>
<body>
<center>
<div class="caja_login">
<form method="POST" action="inicio.php">
<label>Nombre de usuario:</label><input type="text" name="usuario" placeholder="Usuario" required/><br><br>
<label>Contraseña:</label><input type="password" name="contra" placeholder="Contraseña" required /><br><br>
<input type="submit" value="Entrar" name="iniciar-sesion"/><br>
</form>
</div>
<div class ="caja_registro">
<form method="POST">
<h4><label>¿Aún no estás registrado?</label></h4>
<label>Nombre de usuario:</label><br><input type="text" name="nombrerg" placeholder="Nombre de usuario" required><br>
<label>Contraseña:</label><br><input type="password" name="contrarg" placeholder="Contraseña" required><br>
<label>Repetir contraseña:</label><input type="password" name="contrarg2" placeholder="Repita la contraseña" required><br>
<input type="submit" name="registro" value="Crear Cuenta"><br>
</form>
</div>
</center>
<?php //----------------------PARA EL REGISTRO-----------------------
include("conexion.php");
if(isset($_POST['registro'])){
$sql = 'SELECT * FROM cuenta';
$rec = mysqli_query($conexion, $sql);
$verificar =0;
while ($resultado = mysqli_fetch_object($rec)) {
if($resultado->usuario == $_POST['nombrerg']) {//verificamos que el nombre de usuario no existe
$verificar = 1;//si verificar es 1 es que el usuario esta repetido
}
}
if ($verificar == 0) { //si varificar es 0 entonces el nombre no esta repetido
if ($_POST['contrarg'] == $_POST['contrarg2']) {
$nom = $_POST['nombrerg'];
$pw = $_POST['contrarg'];
$pw_en = password_hash($pw, PASSWORD_DEFAULT); //encripta la contraseña
$conexion->query("INSERT INTO cuenta (usuario, contra) VALUES ('$nom','$pw_en')");
mysqli_query($conexion, $sql);
header('Location: inicio.php');
}else{
echo "Intente con otro usuario y contraseña";
}
}else{
echo "Intente con otro usuario y contraseña";
}
}
//-----------------------------PARA EL LOGIN-------------------------
if (isset($_POST['iniciar-sesion'])) { //se comprueba que el boton iniciar sesion fue presionado
$username = $_POST['usuario'];
$sqlLogin= "SELECT usuario,contra FROM cuenta WHERE usuario= '$username'";
$recLogin= mysqli_query($conexion, $sqlLogin);
$sesion= mysqli_fetch_array($recLogin);
if(password_verify($_POST['contra'], $sesion['contra'])){
$_SESSION['username'] = $_POST['usuario'];
header('Location: inicio.php');
}else{
echo "Usuario o contraseña incorrectos";
header('Location: index.php');
}
}
?>
</body>
</html>
<?php
}
?>
But when I log in, whether or not the username and password is correct, it logs in, but I don't know why.
I get no error in the index.php screen.
You are submitting the form to inicio.php which the user should go here if they are logged in. change action=inicio.php in your form.
<form method="POST" action="">
<label>Nombre de usuario:</label><input type="text" name="usuario" placeholder="Usuario"
required/><br><br>
<label>Contraseña:</label><input type="password" name="contra" placeholder="Contraseña"
required/><br><br>
<input type="submit" value="Entrar" name="iniciar-sesion"/><br>
</form>
this is my HTML code:
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>supprimer un moyen</title>
<link rel="stylesheet" href="style.css">
</head>
<body class="example">
<br><br><br>
<form name="f" method="post" action=" supprimer_moyen.php ">
<center><b><h1>supprimer un moyen</h1> </b>
<label>   Entrer le code du moyen : </label>
<input type="text" name="code_moy" value="" placeholder="Code" required>
  <input id="gobutton" type="submit" name="sup" value="Supprimer"><br><br>
</center>
</form>
</body>
</html>
and this is my php code:
<?php
if (isset ($_POST['sup']))
{
$code_moy= $_POST["code_moy"];
$con=mysql_connect("localhost","root","") or die("Echec de connexion au serveur.".mysql_error());
mysql_select_db("ttp",$con) or die("Echec de sélection de la base.".mysql_error());
$sql = "delete from moyen_transport where ID='$code_moy'";
if (mysql_query($sql))
{
echo '<br>';
echo '<h1><center><font color="white"> suppression avec succès <font></center> </h1>';
echo '<center></center>';
}
else
{
echo '<br>';
echo '<h1><center><font color="red"> ce moyen n\'éxiste pas <font></center> </h1> ';
echo '<center></center>';
}
mysql_close();
}
?>
My problem is that no matter what i enter in input the php result is always "suppression avec succès" even if the "ID" dosen't exist in my database!!!
First try using mysqli
second you can use mysqli_num_rows like that
<?php
if (isset ($_POST['sup'])){
$code_moy= $_POST["code_moy"];
$con=mysqli_connect("localhost","root","","ttp") or die("Echec de connexion au serveur.".mysqli_error($con));
$sql = "select * from moyen_transport where ID='$code_moy'";
$query = mysqli_query($con,$sql);
if(mysqli_num_rows($query) == 0){
//No id found
echo '<br>';
echo '<h1><center><font color="red"> ce moyen n\'éxiste pas <font></center> </h1> ';
echo '<center></center>';
}else{
//id found
$sql = "delete from moyen_transport where ID='$code_moy'";
$query = mysqli_query($con,$sql)or die(mysqli_error($con));
echo '<br>';
echo '<h1><center><font color="white"> suppression avec succès <font></center> </h1>';
echo '<center></center>';}}
?>
Try checking if the returned value is empty
$result = mysql_query($sql);
if(!empty($result)){
//success code here
} else {
//fail code here
}
It is correctly printing in UTF-8_encode(), but after i update it , cause i have a button to update the database, it prints with some stupid characters...
I have it on the database in a table, and when i list it on a page and then change something and update it to the database it print with stupid characters
Code where i update:
<?php
if (!isset($_SESSION["auth"])) {
header('Location: index.php?backUrl='.$_SERVER['PHP_SELF']);
exit();
}
$host="localhost"; // Nome do host onde esta o banco de dados. Padrão ‘localhost’
$usuario="root"; // Usuário do Mysql. Padrão ‘root
$senha=""; // Senha do Mysql
$db ="teste"; // Nome da Database
?>
<meta charset="utf-8"/>
<h2 align="center" style="color:white; font-family:"Trebuchet MS", Helvetica, sans-serif; font-size:20px;">Alteração de Orgãos</h2>
<form action="" method="POST" name="alt" id="alt" enctype="multipart/form-data">
<div class="box">
<label>
<textarea rows="20" cols="100" id="texto" name="texto"><?php
$mysqli = mysqli_connect("$host", "$usuario", "$senha")or die("cannot connect");
mysqli_select_db($mysqli,$db)or die("cannot select DB");
$query2 = "Select * from teste";
$stat=$mysqli->query($query2);
if($stat->num_rows>0)
{
while ($row = $stat->fetch_assoc()) {
echo utf8_encode($row["texto"]);
}
} else
{
echo utf8_encode("Não existe nada na página");
}
?></textarea>
</label>
<label >
<input align="center" type="submit" value="Alterar" name="alterar_btn" id="alterar_btn" class="entrar">
</label>
</div>
</form>
<?php
$a1=$b1=$c1=$d1='';
//Alterar
if(isset($_POST['texto']))
{
if(isset($_POST['alterar_btn']))
{
$query="update teste set texto=? where titulo='orgaos'";
$stat = $mysqli->prepare($query);
$stat->bind_param('s',$_POST['texto']);
if ($stat->execute() && $stat->affected_rows>0){
echo "<div><strong>Foi alterado um Orgão!</strong></div>";
}
else{
echo "<div><strong>Nao foi alterado!</strong></div>";
}
$stat->close();
}
}
?>
I'm using a array to get a range between 1011-2371 but I'didnt need all digits. It's a long list thats why I import the CSV to the database.
I want to create a array from a database table.
But I can't get it.
Here's a rough mockup of the old php:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="text" placeholder="1234AB" name="postcode" />
<input type="submit" value="verstuur" />
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$postcode = range(1011,2371);
if(preg_match('/^[1-9][0-9]{3} ?[a-zA-Z]{2}$/', $_POST['postcode'])) {
if(in_array($_POST['postcode'],$postcode)) {
echo 'FreshFoods is beschikbaar bij jou in de buurt.';
} else {
echo 'FreshFoods is nog niet beschikbaar bij u in de buurt.';
}
} else {
echo 'Voer 4 cijfers en 2 letters in als postcode. Voorbeeld 1234AB';
}
}
?>
and this is what I try do get the array from the database:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="text" placeholder="1234AB" name="postcode" />
<input type="submit" value="verstuur" />
</form>
<?php
require_once 'db_config.php';
if($_SERVER['REQUEST_METHOD'] == "POST") {
$postcode = array();
$result = mysql_query("SELECT postcode FROM postcode_check");
if(preg_match('/^[1-9][0-9]{3} ?[a-zA-Z]{2}$/', $_POST['postcode'])) {
if(in_array($_POST['postcode'],$postcode)) {
echo 'FreshFoods is beschikbaar bij jou in de buurt.';
} else {
echo 'FreshFoods is nog niet beschikbaar bij u in de buurt.';
}
} else {
echo 'Voer 4 cijfers en 2 letters in als postcode. Voorbeeld 1234AB';
}
}
?>
the db_config.php file looks like:
<?php
$db = array (
'host' => 'localhost',
'user' => 'root',
'pass' => 'root',
'dbname' => 'testzip'
);
if(!mysql_connect($db['host'], $db['user'], $db['pass']))
{
trigger_error('Fout bij verbinden: '.mysql_error());
}
elseif(!mysql_select_db($db['dbname']))
{
trigger_error('Fout bij selecteren database: '.mysql_error());
}
else
{
$sql = "SET SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY'";
if(!mysql_query($sql))
{
trigger_error('MySQL in ANSI niet mogelijk');
}
}
?>
you have to use mysql_fetch_array or mysql_fetch_assoc to fetch the result from database.
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="text" placeholder="1234AB" name="postcode" />
<input type="submit" value="verstuur" />
</form>
<?php
require_once 'db_config.php';
if($_SERVER['REQUEST_METHOD'] == "POST") {
$postcode = array();
$result = mysql_query("SELECT postcode FROM postcode_check");
while ($row = mysql_fetch_array($result)) {
$postcode[] = $row['postcode'];
}
if(preg_match('/^[1-9][0-9]{3} ?[a-zA-Z]{2}$/', $_POST['postcode'])) {
if(in_array($_POST['postcode'],$postcode)) {
echo 'FreshFoods is beschikbaar bij jou in de buurt.';
} else {
echo 'FreshFoods is nog niet beschikbaar bij u in de buurt.';
}
} else {
echo 'Voer 4 cijfers en 2 letters in als postcode. Voorbeeld 1234AB';
}
}
?>
Try this code.
You need to fetch the result. Your regex will never match your sample data from the db though so you will always get the nog niet message. or voorbeeld. Never 'FreshFoods is beschikbaar bij jou in de buurt'
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="text" placeholder="1234AB" name="postcode" />
<input type="submit" value="verstuur" />
</form>
<?php
require_once 'db_config.php';
if($_SERVER['REQUEST_METHOD'] == "POST") {
$postcode = array();
$result = mysql_query("SELECT postcode FROM postcode_check");
while($row = mysql_fetch_assoc($result)){
$postcode[] = $row['postcode'];
}
if(preg_match('/^[1-9][0-9]{3} ?[a-zA-Z]{2}$/', $_POST['postcode'])) {
if(in_array($_POST['postcode'],$postcode)) {
echo 'FreshFoods is beschikbaar bij jou in de buurt.';
} else {
echo 'FreshFoods is nog niet beschikbaar bij u in de buurt.';
}
} else {
echo 'Voer 4 cijfers en 2 letters in als postcode. Voorbeeld 1234AB';
}
}
?>