Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = $_POST['pesquisa_nome'];
- $nomee = $_POST['pesquisa_usuario'];
- $emaill = $_POST['pesquisa_email'];
- $senhaa = $_POST['rpassword'];
- $DOMDocument = new DOMDocument( '1.0', 'utf-8' );
- $DOMDocument->preserveWhiteSpace = false;
- $DOMDocument->load( 'usuarios.xml' );
- $DOMXPath = new DOMXPath( $DOMDocument );
- if( $DOMXPath->query( './/usuario[email="$emaill"]' )->length >= 1 ){
- echo 'UsuΓ‘rio jΓ‘ cadastrado';
- exit();
- }
- else{
- $DOMDocument = new DOMDocument( '1.0', 'utf-8' );
- $DOMDocument->preserveWhiteSpace = false;
- $DODMocument->formatOutput = true;
- $DOMDocument->load( 'usuarios.xml' );
- $Usuarios = $DOMDocument->getElementsByTagName( 'usuarios' )->item( 0 );
- $Dados = Array(
- 'nome' => $name,
- 'sobrenome' => '',
- 'email' => $emaill,
- 'login' => $nomee,
- 'senha' => $senhaa,
- 'ip' => $_SERVER[ 'REMOTE_ADDR' ]
- );
- $Usuario = $Usuarios->appendChild( $DOMDocument->createElement( 'usuario' ) );
- foreach( $Dados as $index => $data ){
- $Element = $Usuario->appendChild( $DOMDocument->createElement( $index ) );
- $Element->appendChild( $DOMDocument->createCDATASection( $data ) );
- }
- $DODMocument->formatOutput = true;
- $DOMDocument->preserveWhiteSpace = false;
- $DOMDocument->save( 'usuarios.xml' );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment