Jump to content


Photo

Checking variables


  • Please log in to reply
3 replies to this topic

#1 sprinkles

sprinkles
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 22 August 2006 - 08:06 PM

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?

#2 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 22 August 2006 - 08:22 PM

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.
What is the CoronaMatrix?

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 22 August 2006 - 08:27 PM

Can't see anything other that missing exit(); statements after each of the header calls

eg

if($cityid=="") {
header("location: post.php?err=cityid");
exit();
}

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 23 August 2006 - 11:24 AM

Use if/elseif/else statement rather than seperate if statements.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users