asked on
<?php
require_once('include/config.php');
if (isset($_POST['submit']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$age = $_POST['age'];
$school = $_POST['school'];
$college = $_POST['college'];
$university = $_POST['university'];
$company = $_POST['company'];
$personality = $_POST['personality'];
$hobbies = $_POST['hobbies'];
if ( (!empty($_POST["fname"])) && (!empty($_POST["lname"])) && (!empty($_POST["address"])) && (!empty($_POST["phone"])) && (!empty($_POST["age"])) && (!empty($_POST["school"])) && (!empty($_POST["college"])) && (!empty($_POST["university"])) && (!empty($_POST["company"])) && (!empty($_POST["personality"])) && (!empty($_POST["hobbies"])))
{
// Yes, the posted data is available. Escape it for use in query
$fname = mysql_real_escape_string($_POST["fname"]);
$lname = mysql_real_escape_string($_POST["lname"]);
$address = mysql_real_escape_string($_POST["address"]);
$phone = mysql_real_escape_string($_POST["phone"]);
$age = mysql_real_escape_string($_POST["age"]);
$school = mysql_real_escape_string($_POST["school"]);
$college = mysql_real_escape_string($_POST["college"]);
$university = mysql_real_escape_string($_POST["university"]);
$company = mysql_real_escape_string($_POST["company"]);
$personality = mysql_real_escape_string($_POST["personality"]);
$hobbies = mysql_real_escape_string($_POST["hobbies"]);
}
$errors=array();
if(!preg_match('/[A-Za-z]/', $fname))
$errors[]="Name is not valid.";
if(!preg_match('/[A-Za-z]/', $lname))
$errors[]="Name is not valid.";
if(empty($fname))
$errors[]="Please enter your first name.";
if(empty($lname))
$errors[]="Please enter your last name.";
if(empty($address))
$errors[]="Please enter your address.";
if(empty($phone))
$errors[]="Please enter your phone number.";
if(!preg_match('/[0-9]/', $phone))
$errors[]="Phone number is not valid.";
if(empty($age))
$errors[]="Please enter your age.";
if(!preg_match('/[0-9]/', $age))
$errors[]="Age is not valid.";
if(empty($school))
$errors[]="Please enter your schooling details.";
if(empty($college))
$errors[]="Please enter your College details.";
if(empty($university))
$errors[]="Please enter your University details.";
if(empty($company))
$errors[]="Please enter your work experience.";
if(empty($personality))
$errors[]="Please provide informaiton about your personality traits.";
if(empty($hobbies))
$errors[]="Please provide information about your hobbies.";
// $res=mysql_query($sql) or die(mysql_error());
if(sizeof($errors)>0){
echo ("<font color='red'>");
foreach ($errors as $err){
echo ($err."<br/>");
}
echo ("</font>");
exit();
}else{
// Make the unique user key
// $uuk = md5($uid . $pwd . rand());
$sql = "INSERT INTO createprofile (count,fname, lname, address, phone, age, school, college, university,company, personality, hobbies) VALUES ('',$fname','$lname', '$address', '$phone', '$age','school','$college','$university','$company', '$personality', '$hobbies')";
$resu=mysql_query($sql);
// store user details in session array
$_SESSION["fname"] = $fname;
$_SESSION["lname"] = $lname;
$_SESSION["address"] = $address;
$_SESSION["phone"] = $phone;
$_SESSION["age"] = $age;
$_SESSION["school"] = $school;
$_SESSION["college"] = $college;
$_SESSION["university"] = $university;
$_SESSION["company"] = $company;
$_SESSION["personality"] = $personality;
$_SESSION["hobbies"] = $hobbies;
// If create cv form is sucessfull, redirect the user to login_main page
echo "<meta http-equiv='refresh' content='0;url=\"99home.php?page=login_main\"'>";
exit;
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create Profile</title>
</head>
<div>
<h3> PERSONAL DETAILS</h3>
<form name="createprofile" method="post" >
<p>Firstname:<input type="text" name="fname" />
<p>Lastname:<input type="text" name="lname" />
<p>Address: <textarea name="address" cols="45" rows="5"></textarea>
<p>Phone: <input type="text" name="phone" />
<p>Age <input type="text" name="age" /><br/>
<h3> Education Qualification</h3><br/>
<p>School: <textarea name="school" cols="45" rows="5"></textarea>
<p>College: <textarea name="college" cols="45" rows="5"></textarea>
<p>University: <textarea name="university" cols="43" rows="5"></textarea>
<p><h3> Work Experience</h3>
<p>Company Details: <textarea name="company" cols="35" rows="5"></textarea>
<p><h3> Personality Traits</h3>
<p>Personality Traits: <textarea name="personality" cols="35" rows="5"></textarea>
<p><h3>HOBBIES</h3>
<p>HOBBIES: <textarea name="hobbies" cols="45" rows="5"></textarea>
<p><input type="submit" name="Submit" value="Submit" />
</form>
</div>
</body>
</html>
ASKER
VALUES ('',$fname',
should be:VALUES ('','$fname',
ASKER
$sql = "INSERT INTO createprofile (count,fname, lname, address, phone, age, school, college, university,company, personality, hobbies) VALUES ('','$fname','$lname', '$address', '$phone', '$age','school','$college','$university','$company', '$personality', '$hobbies')";
ASKER
$userid = mysql_insert_id();
When you insert a new row in a table, mysql_insert_id() returns the most recently created row's id...ASKER
session_start();
at the top of every page that is connected to a page you're leaving from/going to.
ASKER
ASKER
require_once('include/config.php');
ASKER
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
Open in new window
should actually be:Open in new window
as the name of your submit input is "Submit", not "submit"