la un site de produse/vanzari am o baza de date msql si la pagina de verificare colet cand bag la misto (gdfgds) in casuta ma baga pe pagina de verificare colet unde apar datele nume prenume adresa etc ... si in dreptul Nume nu e nimik scris si apare eroarea codu introdus este gresit si eu vreau cand baga la vrajeala (fsdfgdg) codu sa il redirectioneze pe o pagina de error.html
am bagat header location si un link dar cand dau pe buton la verificare colet ma redirectioneaza pe pagina care este linku bagat si nu mai imi verifica codu daca e bun sau sa dea eroare.
Cod: Selectaţi tot
<?php
//connect to server with username and password
$connection = mysql_connect ("localhost", "xxxx", "xxxx") or die ("Cannot make the connection");
//connect to database
$db = mysql_select_db ("xxx",$connection) or die ("Cannot connect to database");
if ($_SERVER['REQUEST_METHOD']=='POST') {
$track=$_POST['colet'];
//our SQL query
$sql_query = "SELECT * FROM database WHERE track like '$colet'";
//store the SQL query in the result variable
$result = mysql_query($sql_query);
if(mysql_num_rows($result))
{
//output as long as there are still available fields
while($row = mysql_fetch_row($result))
{
// Row 1 is the colet. From row 2 to 7 are the address details. From row 8 to 13 are the service details
$cod=$row[1];
$service=$row[2];
$colet=$row[3];
$weight=$row[4];
$valoare=$row[5];
$inspect=$row[6];
$status=$row[7];
$data1=$row[8];
$data2=$row[9];
$numea1=$row[10];
$addressa=$row[11];
$citya=$row[12];
$statea=$row[13];
$zipa=$row[14];
$countrya=$row[15];
$numeb1=$row[16];
$addressb=$row[17];
$cityb=$row[18];
$stateb=$row[19];
$zipb=$row[20];
$countryb=$row[21];
}
}
//if no fields exist
else
{
echo "<P align=center><STRONG><FONT face=Arial color=#ff0000 size=4>Codul introdus este incorect</FONT></STRONG></P>";
}}
?>