0

estou com um erro e estou tentando corrigir mas não consigo, alguém pode me ajudar? Obrigado.

O erro é: Notice: Undefined index: referrer in C:\xampp\htdocs\brpg\register_content.php on line 71

o arquivo "register_content.php" é:

    <html>
<link href="css/login-form.css" type="text/css" rel="stylesheet" />
<div id="reg_top">
    <table align="center">
        <tr>
            <td>
                <h2>Register a new account</h2>
                <p>We are glad you have considered to be a new member and a part of our community and we wish you a wonderful experience here!<br>
                    Please enter the details for your new account below.</p>
                <p><i>Please note that, we do not allow multiple accounts per user and you are hereby creating an MTA game account.</i></p>
            </td>
        </tr>
    </table>
</div>
<div id="reg_mid">

    <form id="register_form" onsubmit="ajax_submit_register();
            return false;" method="post" action="" onkeypress="resetError();">
        <br>
        <table align="center" class="login-form" style="width: 650px;" cellpadding="2">
            <tr>
                <td style="text-align: left;">
                    <b>Username: </b>
                </td>
                <td style="text-align: left;">
                    <input type="text" id="reg_username" placeholder="" maxlength="30" required/>
                </td>
                <td rowspan="5" valign="bottom" style="text-align: left;">
                    <div style="margin-left: 20px;">
                        <b>Prove you're human:</b>
                        <br>

                        <a href="" onclick="ajax_reload_captcha();
                                return false;"><div id="img_captcha"><img src="captcha/captcha.php" /></div></a><br>
                        <input type="text" id="reg_captcha" placeholder="Enter the text above" maxlength="5" required style="width: 146px;" />

                    </div>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Password: </b>
                </td>
                <td style="text-align: left;">
                    <input type="password" id="reg_password1" placeholder="" maxlength="50" min="6" required/>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Re-type Password: </b>
                </td >
                <td style="text-align: left;">
                    <input type="password" id="reg_password2" placeholder="" maxlength="50" min="6" required/>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Email Address: </b>
                </td>
                <td style="text-align: left;">
                    <input type="email" id="reg_email" placeholder="" maxlength="200" min="1" required/>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Referrer: </b>
                </td>
                <td style="text-align: left;">

                    <?php 
                    $referrer = strip_tags($_GET['referrer']);
                    ?>

                    <input type="text" id="reg_referrer" placeholder="Person who invited you" maxlength="30" value="<?php if ($referrer) echo $referrer; ?>" />
                </td>
            </tr>
            <tr>
                <td colspan="3">
            <center>
                <br>
                <input type="checkbox" id="terms" required/> I have read and agreed to the <a href="http://forums.owlgaming.net/forumdisplay.php?366-Rules" target="_blank">terms and conditions</a>.<br>
                <input type="submit" id="submit_reg" value="Register" style="margin-top: 20px; "/> 
            </center>
            </td>
            </tr>
            <tr>
                <td colspan="3">
                    <div id="error_reg" style="padding-top: 10px; color:red;font-style: italic;font-size: 11px;"></div>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="3">
                    <div id="reg_status"></div>
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="reg_bot">

</div>
<script type="text/javascript" src="js/ajax_register.js"/></script>
</html>
0

2 Respostas 2

2

Mude a declaração da variável:

if($_GET['referrer']){
  $referrer = strip_tags($_GET['referrer']);
} else{
  $referrer = NULL;
}

Assim, quando o $_GET não for enviado, o erro não vai aparecer, pois a variável estará definida como NULL.

Você também pode usar operadores ternários, o que deixaria o código mais limpo.

0
-1

na pagina continua a mesma coisa

coloquei o código, o script agora está assim:

<link href="css/login-form.css" type="text/css" rel="stylesheet" />
<div id="reg_top">
    <table align="center">
        <tr>
            <td>
                <h2>Register a new account</h2>
                <p>We are glad you have considered to be a new member and a part of our community and we wish you a wonderful experience here!<br>
                    Please enter the details for your new account below.</p>
                <p><i>Please note that, we do not allow multiple accounts per user and you are hereby creating an MTA game account.</i></p>
            </td>
        </tr>
    </table>
</div>
<div id="reg_mid">

    <form id="register_form" onsubmit="ajax_submit_register();
            return false;" method="post" action="" onkeypress="resetError();">
        <br>
        <table align="center" class="login-form" style="width: 650px;" cellpadding="2">
            <tr>
                <td style="text-align: left;">
                    <b>Username: </b>
                </td>
                <td style="text-align: left;">
                    <input type="text" id="reg_username" placeholder="" maxlength="30" required/>
                </td>
                <td rowspan="5" valign="bottom" style="text-align: left;">
                    <div style="margin-left: 20px;">
                        <b>Prove you're human:</b>
                        <br>

                        <a href="" onclick="ajax_reload_captcha();
                                return false;"><div id="img_captcha"><img src="captcha/captcha.php" /></div></a><br>
                        <input type="text" id="reg_captcha" placeholder="Enter the text above" maxlength="5" required style="width: 146px;" />

                    </div>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Password: </b>
                </td>
                <td style="text-align: left;">
                    <input type="password" id="reg_password1" placeholder="" maxlength="50" min="6" required/>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Re-type Password: </b>
                </td >
                <td style="text-align: left;">
                    <input type="password" id="reg_password2" placeholder="" maxlength="50" min="6" required/>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Email Address: </b>
                </td>
                <td style="text-align: left;">
                    <input type="email" id="reg_email" placeholder="" maxlength="200" min="1" required/>
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <b>Referrer: </b>
                </td>
                <td style="text-align: left;">

                    <?php 
                                   if($_GET['referrer']){
                                   $referrer = strip_tags($_GET['referrer']);
                                   } else{
                                   $referrer = NULL;
                                   }
                    ?>

                    <input type="text" id="reg_referrer" placeholder="Person who invited you" maxlength="30" value="<?php if ($referrer) echo $referrer; ?>" />
                </td>
            </tr>
            <tr>
                <td colspan="3">
            <center>
                <br>
                <input type="checkbox" id="terms" required/> I have read and agreed to the <a href="http://forums.owlgaming.net/forumdisplay.php?366-Rules" target="_blank">terms and conditions</a>.<br>
                <input type="submit" id="submit_reg" value="Register" style="margin-top: 20px; "/> 
            </center>
            </td>
            </tr>
            <tr>
                <td colspan="3">
                    <div id="error_reg" style="padding-top: 10px; color:red;font-style: italic;font-size: 11px;"></div>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="3">
                    <div id="reg_status"></div>
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="reg_bot">

</div>
<script type="text/javascript" src="js/ajax_register.js"/></script>

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .