Jump to content

Checking variables


sprinkles

Recommended Posts

I have a form that's submitting all of the variables by post.
I'm using this code to remove htmk/javascript and tocheck that they're not empty:

$poster = $_POST['poster'];
$cityid = $_POST['cityid'];
$catid = $_POST['catid'];
$subcatid = $_POST['subcatid'];
$showphone = $_POST['showphone'];

if($showphone=="on") {
$showphone = 1;
} else {
$showphone = 0;
}

$title = $_POST['catid'];
$title = strip_tags($title);
$title = RemoveXSS($title);

$body = $_POST['body'];
$body = strip_tags($body);
$body = RemoveXSS($body);

$location = $_POST['location'];
$location = strip_tags($location);
$location = RemoveXSS($location);

$price = $_POST['price'];
$price = strip_tags($price);
$price = RemoveXSS($price);

$phone = $_POST['phone'];
$phone = strip_tags($phone);
$phone = RemoveXSS($phone);

$email = $_POST['email'];
$email = strip_tags($email);
$email = RemoveXSS($email);

if($cityid=="") {
header("location: post.php?err=cityid");
}
if($catid=="") {
header("location: post.php?err=catid");
}
if($title=="") {
header("location: post.php?err=title");
}
if($body=="") {
header("location: post.php?err=body");
}
if($location=="") {
header("location: post.php?err=location");
}
if($phone=="") {
header("location: post.php?err=phone");
}
if($email=="") {
header("location: post.php?err=email");
}

Every time the script is run, it returns to the form with the blank email error. I've triple-checked the form field's name. EVen if I leave all of the other fields blank, it still goes back on the email. Anyone got any ideas?
Link to comment
https://forums.phpfreaks.com/topic/18331-checking-variables/
Share on other sites

Everything looks right the only thing I'm not sure about is the RemoveXSS function you are using. Try echoing the $email var after you set it to the $_POST['email'] and then after RemoveXSS just to make sure it's being set properly.  You will need to comment out the "header("...")" code in order to see what the results are.
Link to comment
https://forums.phpfreaks.com/topic/18331-checking-variables/#findComment-78777
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.