Modify contact in CONTACT mSQL database

\n"); $in=open("../UserName", "<|"); if ($in<0) { echo("Error: $ERRMSG\n"); fatal(); } $user=readln($in); close($in); $sock = msqlConnect("localhost"); if ($sock < 0) { printf("

%s

\n", $ERRMSG); fatal(""); } if (msqlSelectDB($sock,"contacts") < 0) { printf("

%s

\n", $ERRMSG); fatal(""); } $rbr=$no; if (#$name>30) { $name = strseg($name, 30); } if (#$surname>30) { $surname = strseg($surname, 30); } if (#$titula>20) { $titula = strseg($titula, 20); } if (#$jobtitle>20) { $jobtitle = strseg($jobtitle, 20); } if (#$company>30) { $company = strseg($company, 30); } if (#$dept>30) { $dept = strseg($dept, 30); } if (#$h_street>40) { $h_street = strseg($h_street, 40); } if (#$h_city>20) { $h_city = strseg($h_city, 20); } if (#$h_zip>10) { $h_zip = strseg($h_zip, 10); } if (#$h_country>20) { $h_country = strseg($h_country, 20); } if (#$h_phone>30) { $h_phone = strseg($h_phone, 30); } if (#$w_street>40) { $w_street = strseg($w_street, 40); } if (#$w_city>20) { $w_city = strseg($w_city, 20); } if (#$w_zip>10) { $w_zip = strseg($w_zip, 10); } if (#$w_country>20) { $w_country = strseg($w_country, 20); } if (#$w_phone>30) { $w_phone = strseg($w_phone, 30); } if (#$pager>30) { $pager = strseg($pager, 30); } if (#$mobil_phone>30) { $mobil_phone = strseg($mobil_phone, 30); } if (#$email>70) { $email = strseg($email, 70); } if (#$home_page>70) { $home_page = strseg($home_page, 70); } if (#$fax>20) { $fax = strseg($fax, 20); } if (#$account>50) { $account = strseg($account, 50); } if (#$w_account>50) { $w_account = strseg($w_account, 50); } if ($mailing_addr != "1") { $mailing_addr=0; } if ($public != "1") { $public=0; } echo("

\n"); printf("
serial No: | %s
\n", $no); printf("
Name: | %s, %s
\n", $surname, $name); printf("
Title: | %s
\n", $title); printf("
Job Title: | %s
\n", $jobtitle); printf("
Company: | %s
\n", $company); printf("
Department: | %s
\n", $dept); printf("
Business Address
\n"); printf("
Street: | %s
\n", $w_street); printf("
Zip, City: | %s %s
\n", $w_zip, $w_city); printf("
Country: | %s
\n", $w_country); printf("
Phone: | %s
\n", $w_phone); printf("
Fax: | %s
\n", $fax); printf("
Account No: | %s
\n", $w_account); printf("
Pager: | %s
\n",$pager); printf("
Mobile: | %s
\n",$mobil_phone); printf("
E-mail: | %s
\n",$email); printf("
Home Page: | %s
\n",$home_page); printf("
Home Address
\n"); printf("
Street: | %s
\n", $h_street); printf("
Zip, City: | %s %s
\n", $h_zip, $h_city); printf("
Country: | %s
\n", $h_country); printf("
Phone: | %s
\n",$h_phone); printf("
Account No: | %s
\n",$account); if ($public == 1) { $pbl = "Yes"; } else { $pbl = "No"; } printf("
Public: | %s
\n",$pbl); echo("

\n"); $query = ""; if ($name == strseg(" ", 1, #$name)) { $query = $query + "name=NULL"; } else { $query = $query + "name='" + $name + "'"; } if ($surname == strseg(" ", 1, #$surname)) { $query = $query + ",surname=NULL"; } else { $query = $query + ",surname='" + $surname + "'"; } if ($title == strseg(" ", 1, #$title)) { $query = $query + ",titula=''"; } else { $query = $query + ",titula='" + $title + "'"; } if ($jobtitle == strseg(" ", 1, #$jobtitle)) { $query = $query + ",jobtitle=''"; } else { $query = $query + ",jobtitle='" + $jobtitle + "'"; } if ($company == strseg(" ", 1, #$company)) { $query = $query + ",company=''"; } else { $query = $query + ",company='" + $company + "'"; } if ($dept == strseg(" ", 1, #$dept)) { $query = $query + ",dept=''"; } else { $query = $query + ",dept='" + $dept + "'"; } if ($h_street == strseg(" ", 1, #$h_street)) { $query = $query + ",h_street=''"; } else { $query = $query + ",h_street='" + $h_street + "'"; } if ($h_zip == strseg(" ", 1, #$h_zip)) { $query = $query + ",h_zip=''"; } else { $query = $query + ",h_zip='" + $h_zip + "'"; } if ($h_city == strseg(" ", 1, #$h_city)) { $query = $query + ",h_city=''"; } else { $query = $query + ",h_city='" + $h_city + "'"; } if ($w_street == strseg(" ", 1, #$w_street)) { $query = $query + ",w_street=''"; } else { $query = $query + ",w_street='" + $w_street + "'"; } if ($w_zip == strseg(" ", 1, #$w_zip)) { $query = $query + ",w_zip=''"; } else { $query = $query + ",w_zip='" + $w_zip + "'"; } if ($w_city == strseg(" ", 1, #$w_city)) { $query = $query + ",w_city=''"; } else { $query = $query + ",w_city='" + $w_city + "'"; } if ($h_phone == strseg(" ", 1, #$h_phone)) { $query = $query + ",h_phone=''"; } else { $query = $query + ",h_phone='" + $h_phone + "'"; } if ($w_phone == strseg(" ", 1, #$w_phone)) { $query = $query + ",w_phone=''"; } else { $query = $query + ",w_phone='" + $w_phone + "'"; } if ($fax == strseg(" ", 1, #$fax)) { $query = $query + ",fax=''"; } else { $query = $query + ",fax='" + $fax + "'"; } if ($w_account == strseg(" ", 1, #$w_account)) { $query = $query + ",w_account=''"; } else { $query = $query + ",w_account='" + $w_account + "'"; } if ($account == strseg(" ", 1, #$account)) { $query = $query + ",account=''"; } else { $query = $query + ",account='" + $account + "'"; } if ($pager == strseg(" ", 1, #$pager)) { $query = $query + ",pager=''"; } else { $query = $query + ",pager='" + $pager + "'"; } if ($h_country == strseg(" ", 1, #$h_country)) { $query = $query + ",h_country=''"; } else { $query = $query + ",h_country='" + $h_country + "'"; } if ($w_country == strseg(" ", 1, #$w_country)) { $query = $query + ",w_country=''"; } else { $query = $query + ",w_country='" + $w_country + "'"; } if ($email == strseg(" ", 1, #$email)) { $query = $query + ",email=''"; } else { $query = $query + ",email='" + $email + "'"; } if ($home_page == strseg(" ", 1, #$home_page)) { $query = $query + ",home_page=''"; } else { $query = $query + ",home_page='" + $home_page + "'"; } if ($mobil_phone == strseg(" ", 1, #$mobil_phone)) { $query = $query + ",mobil_phone=''"; } else { $query = $query + ",mobil_phone='" + $mobil_phone + "'"; } $categ = strseg("0" + $categ1, 1, 1) + strseg("0" + $categ2, 1, 1) + strseg("0" + $categ3, 1, 1) + strseg("0" + $categ4, 1, 1); $query = $query + ", categories='" + $categ + "'"; $query = $query + ", public='" + (char)$public + "'"; if (msqlQuery($sock, "UPDATE $user SET $query WHERE rbr=$rbr") < 0) { printf("

%s

\n", $ERRMSG); fatal(""); } else { echo("
Database has been modified!!!\n"); } >