How does the file receive the $ _POST?

Posted on

Coding Problem :

Good morning, I have to do maintenance on an old form and I’m trying to understand how it works …

Below the file form_proposta.php

$msg = "Mais informações de imóvel enviado em " . date("d/m/Y") . ", os dados seguem abaixo: " . chr(13) . chr(10) . chr(10); //nessa linha, estará impresso em que data e hora foi enviado o formulário
$msg .= "Código : " .$codigo . chr(13) . chr(10);
$msg .= "Nome : " . $nome . chr(13) . chr(10); //aqui o campo nome 
$msg .= "E-mail  : " . $email . chr(13) . chr(10); //campo email
$msg .= "Endereço : " . $endereco . chr(13) . chr(10); //campo endereco
$msg .= "Telefone : " . $telefone . chr(13) . chr(10); //campo telefone
$msg .= "Mensagem : " . $mensagem . chr(13) . chr(10); //campo mensagem

$Remetente = $email; //aqui, colocamos que o email digitado seja quem enviou o formulário, pode ser substituido por "Contato do Site", assim, sairá sempre que quem  enviou o email, seja Contato do Site

$para = $email_from;

mail($para, "Proposta do site",$msg,"From: $Remetenten");

Below is the html page

<form action="../exec/form_proposta.php" method="post" >
                    <table align="center" border="0" cellpadding="0" cellspacing="1" >
                        <tr align="left">
                            <td align="left">C&oacute;digo:&nbsp;&nbsp; </td>
                            <td align="left">
                        <tr align="left">
                            <td >Nome:&nbsp;&nbsp;</td>
                            <td align="left"> <input type="text" name="nome" style="width:400px;" class="campo"> </td>

                        <tr align="left">
                            <td align="left"> <input type="text" name="email" style="width:400px;" class="campo">  </td>

                        <tr align="left">
                            <td align="left"> <input type="text" name="telefone" style="width:400px;" class="campo"> </td>

                        <tr align="left">
                            <td align="left"> <input type="text" name="endereco" style="width:400px;" class="campo"> </td>

                        <tr align="left">
                            <td align="left">Mensagem:&nbsp;&nbsp; </td>
                            <td align="left"> <textarea rows="6" name="mensagem" style="width:400px;" class="campo"></textarea> </td>
                          <td colspan="2" align="center"><br>
                            <input type="submit" name="submit" value="Enviar" style="width:100px;" class="campo" /> &nbsp;&nbsp;&nbsp;                  
                            <input type="reset" name="reset" value="Limpar" style="width:100px;" class="campo" />   
                            <input type="hidden" name="codigo" value="{$imo_cod}" />
                            <input type="hidden" name="email_from" value="{$alt_email}" />  

I’m looking at these codes for a long time and I do not understand how this business can work, the php file is not included in nor another file is directly triggered by the form …

At no time did I find the place where the $ _POST are taken and the $ variables assigned …

Basically my conclusion so far is that it works with magic kkk
Can anyone help me understand how this business works?


asked by anonymous 22.09.2014 / 15:09

Answer :

Answer 1 :

When the Register Globals is enabled the querystrings passed in a url will come variables or this is a wide open door for attackers to inject malicious code. In php5.3 this feature was deprecated and php5.4 removed.

To solve the problem you will have to manually assign the variables the value of $ _POST / $ _ GET and gradually go migrating this because this resource is evil level 9999³³³³³³³ .

with register globals on

$msg = "Código : " .$codigo . chr(13) . chr(10);

How to stay

$msg = "Código : " . $_POST['codigo'] . chr(13) . chr(10);


Answer 2 :

Another thing that can be done to not have to mess around is to use extract() .

Since you have a form with correctly defined field names, you could use extract($_POST) , solving the problem;


Answer 3 :

Answer 4 :

Answer 5 :

Answer 6 :

Answer 7 :

Answer 8 :

Answer 9 :

Leave a Reply

Your email address will not be published. Required fields are marked *