PHP SA-MP SITE ERRORS - HELP
#1

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");?>
Reply
#2

By the way, what do you wanna do?
Reply
#3

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"); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)