I have visited numerous sites regarding functions etc. but i'm still stumped. i am currently working on a register user page with a function to process this, I have my functions included at the top prior to the form. i have the form action to php_self and the register.php looks like this
Code: Select all
$submitted = $_POST['submit'];
if (isset($submitted)) {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$aname = $_POST['aname'];
$pass = $_POST['pass'];
$confirmpass = $_POST['confirmpass'];
$email = $_POST['email_address'];
$country = $_POST['country'];
$state = $_POST['state'];
$DOB_day = $_POST['DOB_day'];
$DOB_month = $_POST['DOB_month'];
$DOB_year = $_POST['DOB_year'];
$sex = $_POST['sex'];
$artist = $_POST['artist'];
$producer = $_POST['producer'];
$avatar = $_FILES['avatar'];
$arr = array($fname, $lname, $aname, $pass, $confirmpass, $email, $country, $state, $DOB_day, $DOB_month, $DOB_year, $sex, $artist, $producer, $avatar);
register($arr);
}Code: Select all
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="register">
<table width="90%" border="0" cellpadding="2">
<tr>
<td><label>First Name</label></td>
<td><input name="fname" type="text" size="32" maxlength="32" value="<?php if (isset($submitted)) { echo $fname; } ?>" ></td>
<td><?php echo $error[0] ?></td>
</tr>
<tr>
<td><label>Last Name</label></td>
<td><input name="lname" type="text" size="32" maxlength="32" value="<?php if (isset($submitted)) { echo $lname; } ?>" ></td>
<td><?php echo $error[1] ?></td>
</tr>
<tr>
<td><label>Artist/Band Name</label></td>
<td><input name="aname" type="text" size="32" maxlength="32" value="<?php if (isset($submitted)) { echo $aname; } ?>" ></td>
<td> </td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>now in my function file i have....
Code: Select all
function register($arr) {
$fname = $arr[0];
$lname = $arr[1];
$aname = $arr[2];
$pass = $arr[3];
$confirmpass = $arr[4];
$email = $arr[5];
$country = $arr[6];
$state = $arr[7];
$DOB_day = $arr[8];
$DOB_month = $arr[9];
$DOB_year = $arr[10];
$sex = $arr[11];
$artist = $arr[12];
$producer = $arr[13];
$avatar = $arr[14];
//code to validate and process will go here
}