Hi. I wrote a form that has a radio button and a checkbox and text in it. I tried the same form with a small number before and the data entered the database.
But now I have increased the number of inputs. And gives an error message and is not registered in the database. Error message:
Notice: Undefined index
To solve the problem from the error_reporting function (E_ALL ^ E_NOTICE); I used and the error message was deleted but the data is not sent to the database.
please guide me
Php version 7.4.9
my email: <removed>
Errors of any kind are important, you shouldn’t hide them. Use E_ALL to see all your errors.
To help us help you, cut down your code as small as you can while still failing and add it to your question.
About how many inputs? There are limits on both the number of post form elements and on the total size of the submitted form data.
What index was undefined?
<?php
require_once('config.php');
if(isset($_POST['sub1'])){
$a = $_POST["a"];
$b = $_POST["b"];
$c = $_POST["c"];
$d = $_POST["d"];
$e = $_POST["e"];
$f = $_POST["f"];
$g = $_POST["g"];
$h = $_POST["h"];
$i = $_POST["i"];
$j = $_POST["j"];
$k = $_POST["k"];
$l = $_POST["l"];
$m = $_POST["m"];
$n = $_POST["n"];
$o = $_POST["o"];
$p = $_POST["p"];
$q = $_POST["q"];
$r = $_POST["r"];
$s = $_POST["s"];
$t = $_POST["t"];
$u = $_POST["u"];
$v = $_POST["v"];
$w = $_POST["w"];
$x = $_POST["x"];
$y = $_POST["y"];
$z = $_POST["z"];
$aa = $_POST["aa"];
$ab = $_POST["ab"];
$ac = $_POST["ac"];
$ad = $_POST["ad"];
$ae = $_POST["ae"];
$af = $_POST["af"];
$ag = $_POST["ag"];
$ah = $_POST["ah"];
$ai = $_POST["ai"];
$aj = $_POST["aj"];
$ak = $_POST["ak"];
$al = $_POST["al"];
$am = $_POST["am"];
$an = $_POST["an"];
$ao = $_POST["ao"];
$ap = $_POST["ap"];
$aq = $_POST["aq"];
$ar = $_POST["ar"];
$as = $_POST["as"];
$at = $_POST["at"];
$au = $_POST["au"];
$av = $_POST["av"];
$aw = $_POST["aw"];
$ax = $_POST["ax"];
$ay = $_POST["ay"];
$az = $_POST["az"];
$ba = $_POST["ba"];
$bb = $_POST["bb"];
$bc = $_POST["bc"];
$bd = $_POST["bd"];
$ch1=serialize($am);
$ch2=serialize($ay);
@mysqli_query($con, "SET NAMES utf8");
$sql="Insert into sabt2(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,ba,bb,bc,bd) values('$a','$b','$c','$d','$e','$f','$g','$h','$i','$j','$k','$l','$m','$n','$o','$p','$w','$x','$y','$z','$aa','$ab','$ac','$ad','$ae','$af','$ag','$ah','$ai','$aj','$ak','$al','".$ch1."','$an','$ao','$ap','$aq','$ar','$as','$at','$au','$av','$aw','$ax','".$ch2."','$az','$ba','$bb','$bc','$bd')";
$checkResult= mysqli_query($con, $sql);
if($checkResult){
// echo "Successfully entered!";
echo "<script>alert('اطلاعات با موفقیت ثبت شد');</script>";
}
else{
echo "<script>alert('متاسفانه اطلاعات ثبت نشد.لطفا مجدد تلاش کنید');</script>";
}
}
?>
The total length of my form is 56 items. Which includes text and textara and checkboxes and radio buttons.
Ok. I can’t say for sure without seeing the full error, but you’re probably not setting one of the $_POST
parameters when sending you’re request.
As an aside; your script is not secure against SQL injection attacks. You should look at using prepared statements. You might also want to look at using the PDO extension instead of MySQLi; it’s generally regarded as being easier to use correctly.