SA-MP Forums Archive
PHP SA-MP SITE ERRORS - HELP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PHP SA-MP SITE ERRORS - HELP (/showthread.php?tid=345619)



PHP SA-MP SITE ERRORS - HELP - nGen.SoNNy - 25.05.2012

Hi Guys! I have some problems with my php code... I don't know what's wrong. Please help me! REP ++
pawn Код:
Notice: Undefined index: name in D:\wampserver\www\form.php on line 20 Call Stack #TimeMemoryFunctionLocation 10.0003378784{main}( )..\form.php:0 ">

PHP код:
<?php include("style/header.php");
function 
sec($data) {
            
$data trim(htmlentities(strip_tags($data)));
            if (
get_magic_quotes_gpc()){
                
$data stripslashes($data);
                }
            
$data mysql_real_escape_string($data);
            return 
$data;
        }
?>
<center><form action="<?php $_SERVER['PHP_SELF'];?>" method="post"> 
<b><p><font color="#000000" size="3">Type here your username from the server!</font></p></b>
<input type="text" name="name" class='bg' /></br>
<input type="submit" />
</form></center>
<center><b><p><font color="#000000" size="3"><u>Dynamic Signature Type (1)</u></font></b></center>
<center><img src="1.php?p=<?php echo sec($_POST["name"]); ?>"></center>
<center><b><p><font color="#000000" size="3"><u>Dynamic Signature Type (2)</u></font></b></center>
<center><img src="2.php?p=<?php echo sec($_POST["name"]); ?>"></center>
<center><b><p><font color="#000000" size="3"><u>Dynamic Signature Type (1) Codes: URL/BB/HTML</u></font></b></center>
<center><textarea cols="70" rows="2" readonly onclick="javascript:select();">http://samp.insideplay.ro/1.php?p=<?php echo sec($_POST["name"]); ?></textarea>
<textarea cols="70" rows="2" readonly onclick="javascript:select();">[img]http://samp.insideplay.ro/1.php?p=<?php echo sec($_POST["name"]); ?>[/img]</textarea>
<textarea cols="70" rows="2" readonly onclick="javascript:select();"><img src="http://samp.insideplay.ro/1.php?p=<?php echo sec($_POST["name"]); ?>"/></textarea>
<center><b><p><font color="#000000" size="3"><u>Dynamic Signature Type (2) Codes: URL/BB/HTML</u></font></b></center>
<center><textarea cols="70" rows="2" readonly onclick="javascript:select();">http://samp.insideplay.ro/2.php?p=<?php echo sec($_POST["name"]); ?></textarea>
<textarea cols="70" rows="2" readonly onclick="javascript:select();">[img]http://samp.insideplay.ro/2.php?p=<?php echo sec($_POST["name"]); ?>[/img]</textarea>
<textarea cols="70" rows="2" readonly onclick="javascript:select();"><img src="http://samp.insideplay.ro/2.php?p=<?php echo sec($_POST["name"]); ?>"/></textarea>
</center>
<?php include("style/footer.php");?>



Re: PHP SA-MP SITE ERRORS - HELP - kikito - 25.05.2012

By the way, what do you wanna do?


Re: PHP SA-MP SITE ERRORS - HELP - Mandrakke - 25.05.2012

It is just a warning, means that $_POST["name"] is not set.

to avoid it you need to print the variable only if it is set (after the form is sent);

PHP код:
<?php if(isset($_POST["name"])) echo sec($_POST["name"]); ?>
OR you can do it more easily by using "@" char before an command or variable to not display the error if it occurs (NOT RECOMMENDED)

PHP код:
<?php echo @sec($_POST["name"]); ?>
OR you can use the line below on the top of your script to hide all warning messages (not recommended as well)

PHP код:
error_reporting("E_NOTICE");