Zenika2121 Zenika2121 - 6 months ago 21
PHP Question

Web Pokemon game

I am encountering this error after fixing a lot of other bugs if anyone can help me.

Line 700

<input id="refer" placeholder="<?php echo $txt['not_oblige']; ?>" type="text" name="referer" value="<?php echo $_GET['referer']; ?>" class="form-control" />


Error


Undefined index: referer in C:\wamp\www\PTT\login.php on line 700 Call Stack #TimeMemoryFunctionLocation 10.0010416272{main}( )..\login.php:0 " class="form-control" />


Slice of coding.

</div>
<div class="form-group">
<label for="region"><?php echo $txt['beginworld'] ?></label>
<select name="wereld" class="form-control">
//option field error was here
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Kanto") { echo 'checked'; } ?>>Kanto</option>
<option> <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Jhoto") { echo 'checked'; } ?>Johto</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Hoenn") { echo 'checked'; } ?>>Hoenn</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Sinnoh") { echo 'checked'; } ?>>Sinnoh</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Unova") { echo 'checked'; } ?>>Unova</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Kalos") { echo 'checked'; } ?>>Kalos</option>
</select>
</div>
<div class="form-group">
<input id="agreech" name="agreecheck" id="agreecheck" value="yes" type="checkbox" <?php if(isset($_POST['agreecheck']) && $_POST['agreecheck'] == "yes") { echo 'checked'; } ?>> <label for="agreech"><?php echo $txt['1account_rule']; ?></label>

</div><div class="form-group">
<label for="refer">
<?php echo $txt['referer']; ?></label>

<input id="refer" placeholder="<?php echo $txt['not_oblige']; ?>" type="text" name="referer" value="<?php echo $_GET['referer']; ?>" class="form-control" />
</div>

<div class="form-group">
<input type="submit" value="<?php echo $txt['button']; ?>" name="registreer" class="btn bg-olive btn-block">
</div>

<center>
<table width="100%" border="0">
<tbody><tr>
<td align="Center" valign="Middle" width="102">
<img src="https://static.pkmnstar.com/images/trainers/N.png" border="0">
</td>
<td align="left" valign="Middle"><b>
<font name="verdana" size="1">Bring It On, <br>Show us what you made up of. Fill all the details and informations and agree to the terms and conditions to Begin your Journey...</font></b>

</td>
</tr>
</tbody></table>
</form></div>
<div class="margin text-center">

Answer

PHP cannot find the index referer in the variable $_GET, you should first test if the index exist, Try this:

PHP

<input id="refer" placeholder="<?php echo $txt['not_oblige']; ?>" type="text" name="referer" value="<?php echo (isset($_GET['referer'])) ? $_GET['referer'] : '' ; ?>" class="form-control" /> 
Comments