How to make a form and when the person registers me appear the records of the person and how to associate the two files?

0

IhavethisdesignalreadydoneandmyproblemisinrelatingthefilesandinthephpfilebecauseIdonotknowifitisoktowritetoxmlandalsodonotknowafterwardshowtoopenandsave

<!doctype html>
 
<html>
 <head>
 <title> Formulário </title>
 <meta name="description" content="Formulário">
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
 </head>

 <body>
  <h1> Formulário </h1> 
  <h2> Por favor preencha o formulário abaixo </h2><br />

<form action="file:///C:/Users/André gato/Script_do_Formulario.php" method="post">

<!-- DADOS PESSOAIS-->
<fieldset>
 <legend>Dados Pessoais</legend>
 <table cellspacing="10">
  <tr>
   <td>
    <label for="nome">Nome: </label>
   </td>
   <td align="left">
    <input type="text" name="email">
   </td>
   <td>
    <label for="sobrenome">Sobrenome: </label>
   </td>
   <td align="left">
    <input type="text" name="sobrenome">
   </td>
  </tr>
  <tr>
   <td>
    <label>Nascimento: </label>
   </td>
   <td align="left">
    <input type="text" name="dia" size="2" maxlength="2" value="dd"> 
   <input type="text" name="mes" size="2" maxlength="2" value="mm"> 
   <input type="text" name="ano" size="4" maxlength="4" value="aaaa">
   </td>
  </tr>
   <td>
    <label>NºCC/BI:</label>
   </td>
   <td align="left">
    <input type="text" name="cpf" size="8" maxlength="8"> - <input type="text" name="cpf2" size="4" maxlength="4">
   </td>
 </table>
</fieldset>

<br />
<!-- ENDEREÇO -->
<fieldset>
 <legend>Dados de Endereço</legend>
 <table cellspacing="10">

  <tr>
   <td>
    <label for="rua">Rua:</label>
   </td>
   <td align="left">
    <input type="text" name="rua">
   </td>
   <td>
    <label for="numero">Numero:</label>
   </td>
   <td align="left">
    <input type="number" name="numero" size="4">
   </td>
  </tr>
  <tr>
   <td>
    <label for="bairro">Bairro: </label>
   </td>
   <td align="left">
    <input type="text" name="bairro">
   </td>
  </tr>
  <tr>
   <td>
    <label for="distrito">Distrito:</label>
   </td>
   <td align="left">
    <select name="estado"> 
    <option value="av">Aveiro</option> 
    <option value="be">Beja</option> 
    <option value="br">Braga</option> 
    <option value="br">Bragança</option> 
    <option value="ca">Castelo Branco</option> 
    <option value="co">Coimbra</option> 
    <option value="ev">Évora</option> 
    <option value="fa">Faro</option> 
    <option value="gu">Guarda</option> 
    <option value="le">Leiria</option> 
    <option value="li">Lisboa</option> 
    <option value="po">Portoalegre</option> 
    <option value="po">Porto</option> 
    <option value="sa">Santarém</option> 
    <option value="se">Setúbal</option> 
    <option value="vi">Viana do Castelo</option> 
    <option value="vi">Vila Real</option> 
    <option value="vi">Viseu</option> 
   </select>
   </td>
  </tr>
  <tr>
   <td>
    <label for="cidade">Cidade: </label>
   </td>
   <td align="left">
    <input type="text" name="cidade">
   </td>
  </tr>
  <tr>
   <td>
    <label for="cep">Código Postal: </label>
   </td>
   <td align="left">
    <input type="text" name="cep" size="4" maxlength="5"> - <input type="text" name="cep2" size="3" maxlength="3">
   </td>
  </tr>
 </table>
</fieldset>
<br />

<!-- DADOS DE LOGIN -->
<fieldset>
 <legend>Dados de login</legend>
 <table cellspacing="10">
  <tr>
   <td>
    <label for="email">E-mail: </label>
   </td>
   <td align="left">
    <input type="email" name="email">
   </td>
  </tr>
  <tr>
   <td>
    <label for="imagem">Imagem de perfil:</label>
   </td>
   <td>
    <input type="file" name="imagem" >

   </td>
  </tr>
  <tr>
   <td>
    <label for="login">Login de utilizador: </label>
   </td>
   <td align="left">
    <input type="text" name="login">
   </td>
  </tr>
  <tr>
   <td>
    <label for="pass">Password: </label>
   </td>
   <td align="left">
    <input type="password" name="pass">
   </td>
  </tr>
  <tr>
  </tr>
 </table>
</fieldset>
<p><br />
  <input type="submit" value="Registar">
  <input type="reset" value="Limpar">
</p>
<p>&nbsp;</p>
</form>

 </body>
</html>

<?php

$nome = $_POST['Nome'];
$sobrenome = $_POST['Sobrenome'];
$nccbi = $_POST['NºCC/BI'];
$rua = $_POST['Rua'];
$numero = $_POST['Número'];
$bairro = $_POST['Bairro'];
$distrito = $_POST['Distrito'];
$cidade = $_POST['Cidade'];
$codigop = $_POST['Código Postal'];
$email = $_POST['E-mail'];
$imagemp = $_POST['Imagem de perfil'];
$loginu = $_POST['Login de utilizador'];
$report = $_POST['report'];
$pass = $_POST['Password'];

$xml = new DOMDocument('1.0', 'utf-8');
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->load('file.xml');

$element = $xml->getElementsByTagName('reports')->item(0);

$timestamp = $element->getElementsByTagName('timestamp')->item(0);
$nome = $element->getElementsByTagName('Nome')->item(0);
$sobrenome = $element->getElementsByTagName('Sobrenome')->item(0);
$nccbi = $element->getElementsByTagName('NºCC/BI')->item(0);
$rua = $element->getElementsByTagName('Rua')->item(0);
$numero = $element->getElementsByTagName('Número')->item(0);
$bairro = $element->getElementsByTagName('Bairro')->item(0);
$distrito = $element->getElementsByTagName('Distrito')->item(0);
$cidade = $element->getElementsByTagName('Cidade')->item(0);
$codigop = $element->getElementsByTagName('Código Postal')->item(0);
$email = $element->getElementsByTagName('E-mail')->item(0);
$imagemp = $element->getElementsByTagName('Imagem de perfil')->item(0);
$loginu = $element->getElementsByTagName('Login de utilizador')->item(0);
$report = $element->getElementsByTagName('report')->item(0);
$pass = $element->getElementsByTagName('Password')->item(0);

$newItem = $xml->createElement('reports');

$newItem->appendChild($xml->createElement('timestamp', date("F j, Y, g:i a",time())));;

$newItem->appendChild($xml->createElement('nome', $_POST['Nome']));
$newItem->appendChild($xml->createElement('sobrenome', $_POST['sobrenome']));
$newItem->appendChild($xml->createElement('nccbi', $_POST['NºCC/BI']));
$newItem->appendChild($xml->createElement('report', $_POST['report']));
$newItem->appendChild($xml->createElement('pass', $_POST['Password']));

$xml->getElementsByTagName('entries')->item(0)->appendChild($newItem);

$xml->save('file.xml');

echo "Data has been written.";

?>
    
asked by anonymous 28.06.2017 / 11:49

0 answers