Function not getting called?

This has to be something simple that I just don’t get…
I have a function in file functions.php:
[php]
function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}[/php]
At the beginning of my page, I start php, include functions.php and get my post data:
[php]

<?php /* Page comments go here so I remember what this is supposed to do :) */ include("functions.php"); $id=$_POST['id']; $ip=$_POST['ip']; $email=$_POST['email']; $key=check_input($_POST['key']); $password=check_input($_POST['password']); ?>

[/php]
Later in my code, if I include the following:
[php]

<?php echo "$key and " . check_input($key) . "
"; ?>

[/php]
I can see that $key has not been altered with check_input, however when I use the function in the echo statement, it is called and works.

Why doesn’t it work when I first set $key with the post command?
Thanks… !!

It prolly does work, but you are echoing to an html page.
Check View Source

ok guy thanks last night i got it to work like this

<?php $host="localhost"; $username="myjesus2_test"; $password="test1234"; $database="myjesus2_data"; $table="church"; mysql_connect("$host", "$username", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); $mysql="INSERT INTO $table(date, event) VALUES ('$_POST[date]','$_POST[event]')"; if(!mysql_query($mysql)) die(mysql_error()); echo"Data Inserted"; mysql_close(); ?>

but i need the page to redirect to redirect back to uevent2.php,
i added
header(‘location: uevent2.php’);
but i get

Data Inserted
Warning: Cannot modify header information - headers already sent by (output started at /home/myjesus2/public_html/event2.php:18) in /home/myjesus2/public_html/event2.php on line 19

I think you just posted on the wrong thread lol.
However, in order to modify page headers, that must be the first thing printed to the page. So make sure that piece of code is before any other echo code.

Also, I feel really stupid.

Sponsor our Newsletter | Privacy Policy | Terms of Service