Hello,
im creating a CV website, where companies can add announcements about free work spaces and users can send motivational letters for companies. Moreover, companies can create section about them, users can write CV's.
im stuck in managing everything. This is how i work:
1. Create form for data entry.
form action="processCV.php" method="POST" name="createCV">
ASMENINĖ INFORMACIJA <br/>
Vardas:
<input type="text" name="name"> <br/> <br/>
Pavardė:
<input type="text" name="surename"> <br/> <br/>
Gimimo data: (xxxx-xx-xx):
<input type="text" name="birth_date"> <br/> <br/>
Telefono numeris: (+xxx-xxx-xx-xxx):
<input type="text" name="phone_number"> <br/> <br/>
Elektroninis paštas:
<input type="text" name="email"> <br/> <br/>
Adresas:
<input type="text" name="address"> <br/> <br/>
Miestas:
<input type="text" name="city"> <br/> <br/>
DARBO PATIRTIS <br/>
Laikotarpis:
<input type="text" name="work_length"> <br/> <br/>
Pareigos:
<input type="text" name="postition"> <br/> <br/>
Įmonė:
<input type="text" name="company"> <br/> <br/>
<input type="hidden" name="subaddcv" value="1">
<input type="submit" value="Įkelti" name="add_cv" />
</form>
2. Create process.php, which takes data from form.
<?php
include("include/session.php");
class CVProcess {
/* Class constructor */
function CVProcess() {
global $session, $database;
/* User submitted login form */
if (isset($_REQUEST['add_cv'])) {
$this->procPersonalInfo();
$this->procAddress();
}
if (isset($_REQUEST['edit_cv'])) {
$this->editCVPersonalInfo();
$this->editCVAddressInfo();
}
/**
* Should not get here, which means user_name is viewing this page
* by mistake and therefore is redirected.
*/ else {
header("Location: index.php");
}
}
//Transfer personal info from form to database
function procPersonalInfo() {
global $database, $session;
$username = $_SESSION['username'];
$name = $_POST['name'];
$surename = $_POST['surename'];
$birth_date = $_POST['birth_date'];
$phone_number = $_POST['phone_number'];
$email = $_POST['email'];
$database->addPersonalInfo($username, $name, $surename, $birth_date, $phone_number, $email);
header("Location: " . 'cvpreview.php');
}
//Transfer personal info from form to database
function procAddress() {
global $database;
$username = $_SESSION['username'];
$address = $_POST['address'];
$city = $_POST['city'];
$database->addAddress($username, $address, $city);
}
}
/* Initialize process */
$cv_process = new CVProcess;
?>
3. From process.php, im sending data to database function in database.php.
/Add CV personal data
function addPersonalInfo($username, $name, $surename, $birth_date, $phone_number, $email) {
$q = "INSERT INTO " . TBL_CV_PERSONAL . " VALUES ('$username', '$name', '$surename', '$birth_date', '$phone_number', '$email')";
return mysql_query($q, $this->connection);
}
//Add CV address data
function addAddress($username, $address, $city) {
$q = "INSERT INTO " . TBL_CV_ADDRESS . " VALUES ('$username', '$address', '$city')";
return mysql_query($q, $this->connection);
}
Moreover, this is just for CV creation. Preview and edit are new files like cvPreview.php and cvEdit.php. Im not quite sure wheter this is good way for creating a website. I mean, for me, it looks like im creating too much new pages and my work is not efficient at all. Hope my explaination is clear enought.