![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 1
OS: Windows XP SP3
|
hello guys!
i'm newbie to php and now trying to make some nice stuff. i'm developing a project to manage some data related to public health using php and xml. well, but going to the point, i have a page with forms like this: Code:
<html> <head> <title>Incluir Estabelecimento</title> </head> <body> <form action="salva.php" method="post"> <p><b>Nome*: </b> <input type="text" name="nome" /></p> <p><b>Responsável*: </b> <input type="text" name="resp" /></p> <p><b>Endereço*: </b> <input type="text" name="ende" /></p> <p><b>Telefone: </b> <input type="text" name="tele" /></p> <p><b>Ramo de atividade: </b> <input type="text" name="ramo" /></p> <p><b>Emissão do último alvará: </b> <input type="text" name="emis" /></p> <p><b>Vencimento do alvará: </b> <input type="text" name="venc" /></p> <input type="hidden" value="OK" name="esco" /> <p><input type="submit" value="Incluir dados" name="incl" /></p> </body> </html> Code:
<?php
$tabela = new DOMDocument('1.0', 'utf8');
$tabela->formatOutput = true;
$nomes = trim($_POST['nome']);
$resps = trim($_POST['resp']);
$endes = trim($_POST['ende']);
$teles = trim($_POST['tele']);
$ramos = trim($_POST['ramo']);
$emiss = trim($_POST['emis']);
$vencs = trim($_POST['venc']);
$spn = strlen($nomes);
$spr = strlen($resps);
$spe = strlen($endes);
// ---------------------------------
function escreveNovo() {
if (!isset($nomes) || !isset($resps) || !isset($endes)) {
echo("Preencha os campos obrigatórios! <a href=\"http://localhost/visa/inclui.php\">Voltar </a>");
exit;
}
else {
header("Content-type: text/xml");
$indi = strpos($resps, " ");
$espa = $indi - 1;
$titu = substr($resps, 0, $espa);
$pri = $tabela->createElement("estabelecimento");
$tabela->appendChild($pri);
$sec = $tabela->createAttr("dono");
$pri->appendChild($sec);
$ter = $tabela->createElement("nome");
$pri->appendChild($ter);
$qua = $tabela->createElement("responsavel");
$pri->appendChild($qua);
$qui = $tabela->createElement("endereco");
$pri->appendChild($qui);
$sex = $tabela->createElement("telefone");
$pri->appendChild($sex);
$set = $tabela -> createElement("ramo");
$pri->appendChild($set);
$oit = $tabela -> createElement("emissao");
$pri->appendChild($oit);
$non = $tabela -> createElement("vencimento");
$pri->appendChild($non);
$utit = $tabela->createTextNode($titu);
$sec->appendChild($utit);
$enom = $tabela->createTextNode($nomes);
$ter->appendChild($enom);
$pser = $tabela->createTextNode($resps);
$qua->appendChild($pser);
$edne = $tabela->createTextNode($endes);
$qui->appendChild($edne);
$elet = $tabela->createTextNode($teles);
$sex->appendChild($elet);
$omar = $tabela->createTextNode($ramos);
$set->appendChild($omar);
$sime = $tabela->reateTextNode($emiss);
$oit->appendChild($sime);
$cnev = $tabela->createTextNode($vencs);
$non->appendChild($cnev);
}
}
// -----------------------------------------
escreveNovo();
$tabela->save('estab.xml');
?>
i'm really stuck with that. Another important thing is that i've already tried to echo the strings from the forms, and they are actually there, working perfectly! thanks in advance for the support! |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,446
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: newbie having trouble with php and forms
Try this:
Replace PHP Code:
PHP Code:
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
![]() |
| Thread Tools | |
|
|