I have do a update profile for company where they can update after view their profile, but it cannot function... I need to submit the whole job portal soon, but still got many problem in my coding, could someone help me... Thanks a lot..
Below is the error:
Notice: Undefined index: company_ID in C:\Apache2\Apache2\htdocs\comProfile_update.php on line 28
where line 28 is
[PHP]if(is_numeric($_GET['company_ID'])) {[/PHP]
My whole coding as below:
[PHP]<?php
error_reporting(E_ALL);
//ob_start();
session_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 (isset($_POST['submit'])){//handle the form
//define query
$query= "UPDATE company SET companyName='$_POST[companyName]', companyType='$_POST[companyType]', conatctName='$_POST[contactName]', contactNum='$_POST[contactNum]', fax='$_POST[fax]', contactAdd='$_POST[contactAdd]',
city='$_POST[city]', postcode='$_POST[postcode]', state='$_POST[state]', country='$_POST[country]', description='$_POST[description]',
WHERE company_ID={$_SESSION['company_ID']}";
$r= mysql_query($query); //execute the query.
//report on the result.
if(mysql_affected_rows()==1){
print'<p>The profile has been updated.</p>';
} else{
print'<p>Could not update the profile because:<b>'.mysql_error().'</b>. The query was $query.</p>';
}
}else{//Display the entry in a form.
//check for a valid entry ID
if(is_numeric($_GET['company_ID'])) {
//define the query.
$query= "SELECT * FROM company WHERE company_ID={$_GET['company_ID']}";
if ($r = mysql_query($query)) { //run the query.
$row=mysql_fetch_array($r) ; //retrieve the information
?>
<form action='comProfile_update.php' method='post'>
<div align='center'><font size='+3' face='Verdana'><strong>COMPANY
PROFILE </strong> </font></div>
<table width="600" border="0">
<tr>
<td width="217"><font color="#000000" face="Verdana">Company Name<font color="#FF0000">*</font>
</font></td>
<td width="30"><div align="center"><strong>:</strong></div></td>
<td width="339"><input name="companyName" type="text" maxlength="20" value=".$row['companyName']."></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">Company Type</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><select name="companyType">
<option selected>".$row['companyType']."</option>
<option>Employer</option>
<option>Recruiter</option>
</select></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">Contact Name<font color="#FF0000">*</font></font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input type="text" name="contactName" value=".$row['contactName']."></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">Contact Number<font color="#FF0000">*</font></font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input name="contactNum" type="text" maxlength="11" value=".$row['contactNaum']."></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">Fax</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input name="fax" type="text" maxlength="11" value=".$row['fax']."></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">Contact Address<font color="#FF0000">*</font></font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><textarea name="contactAdd" cols="33" rows="3">".$row['contactAdd']."</textarea></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">City</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input name="city" type="text" maxlength="50" value=".$row['city']."></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">Postcode</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input name="postcode" type="text" maxlength="5" value=".$row['postcoode']."></td>
</tr>
<tr>
<td><font color="#000000" Face="Verdana">State</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input type="text" name="state" value=".$row['state']."></td>
</tr>
<tr>
<td><font color="#000000" Face="Verdana">Country</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><input name="country" type="text" value=".$row['country']."></td>
</tr>
<tr>
<td><font color="#000000" face="Verdana">Description</font></td>
<td><div align="center"><strong>:</strong></div></td>
<td><textarea name="description" cols="33" rows="3">".$row['description']."</textarea></td>
</tr>
</tr>
</table>
<p>
</div>
<p>
<input type='hidden' name='company_ID' value=".$_GET['company_ID'].">
<input name='submit' type='submit' id='submit' value='Update Profile'>
</p>
</div>
<?
}else{//couldnt get information.
print'<p>Could not retrieve the entry because:<b>'.mysql_error().'</b>. The query was $query.</p>';
}
} else{//No ID set
print'<p><b>You must have made a mistake in using this page.</b></p>';
}
} //End of main IF.
mysql_close(); //close the database connection.
?>
[/PHP]