PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$fname = ValidateInput($_POST['fname']);
$lname = ValidateInput($_POST['lname']);
function add() {
// if ($_POST['edit'] == 'edit') {
query database for records here
}else{
// call for the stored $_POST data here
}
Thanks
Last edited by bob_the _builder on Tue Oct 10, 2006 3:42 pm, edited 1 time in total.
That's a scope issue. Variables created inside the funcion can only be seen inside that function unless you specify otherwise. There are to approaches to what you're doing here:
Why are you assigning $fname = $_POST['fname'];?
$fname and $lname are not superglobal, when post() ends they end to exist.
What do you want to achieve/What's the purpose of the code?
Its so I can share the same form to edit records and create new records ...
$fname = $row['fname']
for an edit or
$fname = $_POST['fname']
the post data being used when the form is reloaded from mandetory fields, and wanting them held in a function so I can call on the post(); to place into the database when the form is successfully submited.
The former is a function definition. It does not represent the variable names that are being passed to the function, but the variable names as they would be known inside the function itself.
The latter is the function call, since three (required) arguments were defined for the function, three must be passed in.
Inside the function, unless you pass the variable as argument, other variable cannot be accessed unless you call global variable. So, you better call the global POST, GET variable by writing the statement :
$_POST, $_GET, $_COOKIE are already globals (superglobals actually) so you don't need to define them as globals in any functions. see Predefined variables