Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have a simple form in a html with a process.php file like:Code: Select all
<?php
include("global.inc.php");
$errors=0;
$error="Some error message.<ul>";
pt_register('POST','CNP');
pt_register('POST','Nume');
pt_register('POST','Prenume');
if($CNP==" "){
$errors=1;
$error.="<li>Error...";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){
$error.="<li>invalid email address";
$errors=1;
}
if($errors==1) echo $error;
else{
$link = mysql_connect("localhost","user","password");
mysql_select_db("db",$link);
$idtest=$_POST[id];
$quer = "SELECT id FROM pasagger WHERE id=$idtest";
$rez = mysql_query($quer);
if(mysql_num_rows($rez)) {
echo "Duplicate ID";
} else {
$query="insert into pasager (cnp,nume,prenume) values ('".$CNP."','".$Nume."','".$Prenume."')";
mysql_query($query);
}
header("Location: http://www.google.com/");
?><?php
}
?>as u can see there is a if testing for duplicate id...if in the form I put an id that already is in the database then I will get the error (Duplicate ID) but under I also get
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\nusphere\techplat\apache\htdocs\site\pazbor.php:31) in c:\program files\nusphere\techplat\apache\htdocs\site\pazbor.php on line 33(the line with header(...)
why? what am I doing wrong?
arborint | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]