Jazak Allah.
Jazak Allah.
Nice
ASSALAM O ALYKUM SIR G,
PHP KI CLASS KA BOHAT BOHAT SHUKRIA.
mein is waqt xampp-win32-1.7.4-VC6-installer use kar raha hoon jis mein class 11, page 13 per use kiye gaee array ko cleanStr function mein se guzarein to error generate hota he.
foreach($ar as $key => $value){
$value = cleanStr($value);
error: trim() expects parameter 1 to be string, array given in (path of file)\application.php on line 7.
agar is 1 line ko ignore kar dia jai
// $value = cleanStr($value);
to form theek ho jata he is k ilawa b neechay agar male ya female ko select na kia gaya ho to error generate hota he.
error:
Notice: Undefined index: gender in (file path)\application.php on line 55
Notice: Undefined index: skills in (filepath)\application.php on line 60.
in masail ka hal mein ne search karne k bad ye nikala he k cleanStr ko array pr na use kia jai r $gender r $skills se pehlay @ ka izafa kar dia jai. kuch is tarah
@$gender = $_POST['gender'];
@$skills = $_POST['skills'];
@ wala solution waqaee work karta he.
ap se is k side effects ka poochna he k aaya @ use karne se koi problem to nahi hogi.
Apki Help ka bohat bohat shukria.
Thanks Shakel Bhai
nice
thanks
Hello zinda bad,
cleanStr ka jo custom function hai wo string kay liyay hi hai.. array kay liyay nahi. and dosri baat. @ warnings and errors ko hide karnay kay liyay hota hai.. best practice ye hai kay ap @ use na karein. but jahan kafi bari application ki baat hoti hai wahan @ use karna par jata hai. but ap ki condition mei @ ki need nahi. ap koshish karein kay error ko debug karein.
best hy
i have attache the form.html for layout code of this class
//app.php code for this file
<?php
function cleanStr($str)
{
$cStr=trim($str);
$cStr=htmlspecialchars($cStr);
$cStr=addslashes($cStr);
return $cStr;
}
function emptyFields($ar)
{
if(!is_array($ar))
{
print "The argument must be an Array";
return false;
}
foreach($ar as $key => $value){
if(empty($value))
{
print "<b>".ucwords($key)."</b> Must not be empty.please click the browser
back button and correct it";
return false;
}
}
return true;
}
if(!emptyFields($_POST)){
exit();
}
function isEligible($skills,$age){
$age=intval($age);
if(count($skills)==0){
print ("you donot have any skill");
return false;
}
if($age<23 ||$age>35){
print ("your age must be between 23 and 35");
return false;
}
return true;
}
$name=cleanStr($_POST['name']);
$phone=cleanStr($_POST['phone']);
$email=cleanStr($_POST['email']);
$address=cleanStr($_POST['address']);
$gender=$_POST['gender'];
$city=$_POST['city'];
$age=(int)cleanStr($_POST['age']);
$skills=$_POST['skills'];
if(!isEligible($skills,$age)){
exit();
}
print "<h4>Thank you ".$name." for your interset in this job.we will contact you soon.</h4>";
print "We have recived following Information about you.<br/>";
print "Name : ".$name."<br/>";
print "Phone : ".$phone."<br/>";
print "Email : ".$email."<br/>";
print "Address : ".$address."<br/>";
print "Gender : ".$gender."<br/>";
print "City : ".$city."<br/>";
print "Age : ".$age."<br/>";
print "your skills : ";
foreach($skills as $value){
print $value.",";
}
?>
Thanks alot Shakeel bhaie
sir, mujhy is program ko run karny mai error ka samna karna par raha hai. jub main form.html mai submit per click karta hon tu wo mujhy ye error daita hai
Notice: Undefined variable: cstr in D:\xampp\htdocs\application.php on line 5
Notice: Undefined variable: cstr in D:\xampp\htdocs\application.php on line 6
jab k mai ye code likh raha hon.
<?php
//clean white spaces and special characters from values
function cleanStr($str){
$cStr = trim ($str);
$cStr = htmlspecialchars($cstr);
$cStr = addslashes($cstr);
return $cStr;
}
?>
Plz help..
Bookmarks