hi guys i am starting to learn how to create php functions to expand my coding into the realm of real scalable and fast developing without doing so much line by line that i have been doing so far.
Below is my first function and it works nicely though incomplete i am still going though a lot of documentation and such to make sure it checks for as many possible injection attacks and errors as possible. Now what i am having problems with is i would like to just use.
Instead of the more cumbersome.
Anyone got any hints of how to do that, my lecturer stepped me though it on visual basic but PHP is a little different and i have not been able to find much information on accomplishing it.
Below is my first function and it works nicely though incomplete i am still going though a lot of documentation and such to make sure it checks for as many possible injection attacks and errors as possible. Now what i am having problems with is i would like to just use.
PHP:
<?php $val1 = form_text_validate($_POST['username']);?>
PHP:
<?php $val1 = form_text_validate($value = $_POST['username']);?>
Anyone got any hints of how to do that, my lecturer stepped me though it on visual basic but PHP is a little different and i have not been able to find much information on accomplishing it.
PHP:
<?php
function form_text_validate($value)
{
// First stage is to convert the string to html specialchars for php to stop injection. //
$value_hsc = htmlspecialchars(addslashes($value));
if ($value_hsc == "")
{
return "false";
}
else
{
if (is_numeric($value_hsc))
{
return "false";
}
else
{
return "true ".stripslashes($value_hsc)."";
}
}
}
?>