473,385 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

job post code cannot post into database

127 100+
Below is my job post code, it cannot post into database... WHAT IS THE PROBLEM OF IT??



[PHP]<?php
session_start();
ob_start();

//connect to server and select database

$conn=mysql_connect("localhost", "root", "") or die (mysql_error());
mysql_select_db("ums e-job portal", $conn) or die(mysql_error());

//If the form was submitted, process it.
if (isset($_POST['submit'])){

$problem=FALSE;

//check for empty value in each mandatory field.
if (empty($_POST['jobTitle'])||empty($_POST['jobType'])||empty($_POST['jobCategory'])||empty($_POST['jobPosition'])||empty($_POST['jobLocation'])||empty($_POST['mRequirement'])||empty($_POST['jobDescription'])){
$problem=TRUE;
echo '<p>Please make sure you enter all the required fields!</p>';
}

//if no problem then insert values into the abstract table in the database.
if (!$problem){

$query = "INSERT INTO job values ( '', '$_SESSION[company_ID]', '$_SESSION[companyName]', '$_SESSION[contactName]' , '$_SESSION[emailAdd]', '$_SESSION[contactNum]', '$_SESSION[contactAdd]', '$_POST[jobTitle]', '$_POST[jobType]', '$_POST[jobCategory]', '$_POST[jobPosition]', '$_POST[jobLocation]', '$_POST[mRequirement]', '$_POST[jobDescription]', now() )";


if(mysql_query($query)){
echo 'The job has been posted.<br>';
exit ();

}else{
echo 'The job could not be submitted. Because:'.mysql_error();
}
}#end of insert values if.


}#end of submit if...



// construct SQL statement
$sql =mysql_query("SELECT * FROM company WHERE company_ID='{$_SESSION['company_ID']}'");
$rows=@mysql_fetch_array($sql)
?>[/PHP]

[HTML]<form name="act" method="post" action="jobPost.php">
<table width="600" border="0">
<tr>
<td colspan="3"><font color="#000000"><strong>COMPANY CONTACT INFORMATION</strong></font></td>
</tr>
<tr>
<td width="217"><font color="#000000">Company Name</font><font color="#000000">&nbsp;</font></td>
<td width="30"><div align="center"><strong>:</strong></div></td>
<td width="339"><input name="companyName" type="text" maxlength="30" value="<? echo $rows['companyName'];?>"></td>
</tr>
<tr>
<td width="217"><font color="#000000">Contact Name</font><font color="#000000">&nbsp;</font></td>
<td width="30"><div align="center"><strong>:</strong></div></td>
<td width="339"><input name="contactName" type="text" maxlength="30" value="<? echo $rows['contactName'];?>"></td>
</tr>
<tr>
<td><font color="#000000">Email Address</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input name="emailAdd" type="text" maxlength="50" value="<? echo $rows['emailAdd'];?>"></td>
</tr>
<tr>
<td><font color="#000000">Contact Number</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input name="contactNum" type="text" maxlength="11" value="<? echo $rows['contactNum'];?>"></td>
</tr>
<tr>
<td><font color="#000000">Contact Address</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><textarea name="contactAdd" cols="30" rows="3"><? echo $rows['contactAdd'];?></textarea> </textarea>
</td>
</tr>
<tr>
<td colspan="3"><div align="center"></div></td>
</tr>
<td colspan="3"><font color="#000000"><strong>JOB INFORMATION</strong></font></td>
<tr>
<td width="217"><font color="#000000">Job Title</font><font color="#000000">&nbsp;</font></td>
<td width="30"><div align="center"><strong>:</strong></div></td>
<td width="339"><input name="jobTitle" type="text" maxlength="30"></td>
</tr>
<tr>
<td><font color="#000000">Job Type</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><select name="jobType">
<option selected></option>
<option>Permanent/Full Time</option>
<option>Temporary/Part Time</option>
<option>Internships</option>
</select></td>
</tr>
<tr>
<td><font color="#000000">Job Category</font> </td>
<td><div align="center"><strong>:</strong></div></td>
<td><select name="jobCategory">
<option selected></option>
<option>Accounting</option>
<option>Advertising</option>
<option>Agriculture</option>
<option>Banking</option>
<option>Biotechnology</option>
<option>Chemical Eng</option>
<option>Chemistry</option>
<option>Clerical/Admin</option>
<option>Customer Service</option>
<option>Education</option>
<option>Electronics Eng</option>
<option>Food Tech</option>
<option>General Workers</option>
<option>Graphics</option>
<option>Healthcare</option>
<option>Hotel/Food</option>
<option>Human Resources</option>
<option>IT/Computer</option>
<option>Journalist/Editor</option>
<option>Manufacturing</option>
<option>Marketing</option>
<option>Mechanical Eng</option>
<option>Media/Entertain</option>
<option>Personal Care</option>
<option>Publishing</option>
<option>Purchasing</option>
<option>Quantity Survey</option>
<option>Sales</option>
<option>Science/Tech</option>
<option>Secretarial</option>
<option>Social Services</option>
<option>Training</option>
<option>Others</option>
</select></td>
</tr>
<tr>
<td><font color="#000000">Job Position Level</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><select name="jobPosition">
<option selected></option>
<option>Senior Manager</option>
<option>Manager</option>
<option>Senior Executive</option>
<option>Junior Executive</option>
<option>Non-Executive</option>
<option>Fresh/Entry Level</option>
<option>Others</option>
</select></td>
</tr>
<tr>
<td><font color="#000000">Job Location</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><select name="jobLocation">
<option selected></option>
<option>Perlis</option>
<option>Penang</option>
<option>Kedah</option>
<option>Perak</option>
<option>Kelantan</option>
<option>Terengganu</option>
<option>Pahang</option>
<option>Selangor</option>
<option>Kuala Lumpur</option>
<option>Negeri Sembilan</option>
<option>Melaka</option>
<option>Johor</option>
<option>Labuan</option>
<option>Sabah</option>
<option>Sarawak</option>
</select></td>
</tr>
<tr>
<td colspan="3"><font color="#000000">Minimal Requirement</font></td>
</tr>
<tr>
<td height="75" colspan="3"> <textarea name="mRequirement" cols="66" rows="4"></textarea></td>
</tr>
<tr>
<td colspan="3"><div align="center"></div></td>
</tr>
<tr>
<td colspan="3">Job Description</td>
</tr>
<tr>
<td colspan="3"><font color="#000000">
<textarea name="jobDescription" cols="66" rows="4"></textarea>
</font></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Post Job" type="submit" id="Post Job" value="Post Job">
</div></td>
<td><div align="center">
<input type="reset" name="Reset" value="Reset">
</div></td>
</tr>
</table>
<p>&nbsp;</p>
</form>[/HTML]
Feb 19 '07 #1
3 2096
xwero
99
Below is my job post code, it cannot post into database... WHAT IS THE PROBLEM OF IT??



[PHP]<?php

mysql_select_db("ums e-job portal", $conn) or die(mysql_error());

?>[/PHP]
Are those 3 databases or is that the name of one database?

It's not good practice to have spaces in a databasename or in fieldnames for that matter.
Feb 19 '07 #2
bb nicole
127 100+
Are those 3 databases or is that the name of one database?

It's not good practice to have spaces in a databasename or in fieldnames for that matter.


Is a name for 1 database...
i know, but i think the problem is not in there coz i have done others function which can work with this database name.. Thanks..
Feb 19 '07 #3
xwero
99
What is the error you see if you post or is there no error at all?

[PHP]$query = "INSERT INTO job values ( '', '$_SESSION[company_ID]', '$_SESSION[companyName]', '$_SESSION[contactName]' , '$_SESSION[emailAdd]', '$_SESSION[contactNum]', '$_SESSION[contactAdd]', '$_POST[jobTitle]', '$_POST[jobType]', '$_POST[jobCategory]', '$_POST[jobPosition]', '$_POST[jobLocation]', '$_POST[mRequirement]', '$_POST[jobDescription]', now() )";[/PHP]

are you sure that are all the fields in the table?

The following snippet is more secure and easier to maintain

[PHP]
$jobtitle = $_POST[jobTitle];
$jobtype = $_POST[jobType];
$jobcategory = $_POST[jobCategory];
$jobposition = $_POST[jobPosition];
$joblocation] = $_POST[jobLocation];
$mRequirement = $_POST[mRequirement];
$jobDescription = $_POST[jobDescription];
// add post variable checks
$query = 'INSERT INTO job (field,names) VALUES (post,variables,and other)';
[/PHP]

If you do it like this the fieldnames and values must be equal in amount and you don't have to know how many other fields there are or where they are
Feb 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Nomen Nescio | last post by:
can anyone be so kind as to look at http://www.mysolution.ws/HYPOCRITE.php and let me know why it isn't passing the form data to http://www.mysolution.ws/insertHYPOCRITES.php for the most...
1
by: srihari | last post by:
Hai I have installed db2 8.1 on linux machine. The current db2 users are instance user(db2inst1), fenced user(db2fenc1) and db2as(administration server). To start using the database do I have to...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
6
by: Mark | last post by:
i'm using an html form to submit comments to a database. the form is on the same page where the comments are being displayed. if you hit submit, your comment appears as it should, but then if you...
3
by: Brano | last post by:
HI all, I am looking to post XML data to a particular page and also redirect to the same page. I have coded a WebReqest code in page0 that posts the XML to the page1 and then the page1 in its...
8
by: Challenge | last post by:
Hi, I got error, SQL1768N Unable to start HADR. Reason code = "7", when I tried to start hadr primary database. Here are the hadr configuration of my primary db: HADR database role ...
2
daJunkCollector
by: daJunkCollector | last post by:
Hey, I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen: 1. The form...
3
by: ctrap | last post by:
Hi Everyone, Here's my situation: I'm making a website for an employment agency, there is a page where potential employees can visit and "pre-register". When the submit button is hit the...
8
by: Kurda Yon | last post by:
Hi, I have to decide which form-method I should use (GET or POST). I found the following recomendation: If the service associated with the processing of a form has side effects (for example,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.