更新配置文件无法正常工作:注意:未定义的索引:company_ID [英] update profile cannot function: Notice: Undefined index: company_ID

查看:148
本文介绍了更新配置文件无法正常工作:注意:未定义的索引:company_ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为公司做了更新配置文件,他们可以在查看他们的个人资料后更新,但它无法运行...我需要尽快提交整个工作门户网站,但我的编码仍然有很多问题,有人可以帮我吗......非常感谢..

下面是错误:

公告:未定义指数:COMPANY_ID在C:\Apache2\Apache2\htdocs\comProfile_update第28行的.php

第28行是

[PHP] if(is_numeric($ _ GET [''company_ID''])){[/ PHP]



我的整个编码如下:

[PHP]<?php

error_reporting(E_ALL);

// ob_start();

session_start();


//连接服务器并选择数据库

$ conn = mysql_connect(''localhost'',''root'','''')

或die(mysql_error());

mysql_select_db( ''ums e-job portal'',$ conn)或die(mysql_error());


if(isset($ _ POST [''submit''])){/ /处理for m

//定义查询

$ 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 [国家] '',描述= '' $ _ POST [描述] '',

其中COMPANY_ID = {$ _ SESSION [ '' COMPANY_ID '']}英寸;

$ r = mysql_query($ query); //执行查询。


//报告结果。

if(mysql_affected_rows()== 1){

打印''< p>个人资料已更新。< / p>'';

}其他{

打印''< p>无法更新个人资料,因为:< b>''。mysql_error()。''< / b>。查询是$ query。< / p>'';

}


} else {//在表单中显示条目。


//检查有效的条目ID

if(is_numeric($ _ GET [''company_ID''])){

/ /定义查询。

$ query =" SELECT * FROM company WHERE company_ID = {$ _ GET [''company_ID'']}" ;;

if($ r = mysql_query($ query)){//运行查询。

$ row = mysql_fetch_array($ r); //检索信息

?>

< 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">公司名称< font color ="#FF0000"> *< / font>

< / font>< / td>

< td width =" 30">< div align =" center">< strong>:< / strong>< / div>< / td>

< td width =" 339">< input name =" companyName"类型= QUOT;文本" MAXLENGTH = QUOT; 20" value ="。$ row [''companyName'']。">< / td>

< / tr>

< tr>

< td>< font color ="#000000" face =" Verdana">公司类型< / font>< / td>

< td>< div align =" center">< strong>:< / strong>< / div>< / td>

< td>< select name =" companyType">

< option selected>" 。$ row [''companyType'']。"< / option>

< option>雇主< /选项>

<选项>招聘人员< /选项>

< / select>< / td>

< / tr>

< tr>

< td>< font color ="#000000" face =" Verdana">联系人姓名< font color ="#FF0000"> *< / font>< / font>< / td>

< td>< ; div align =" center">< strong>:< / strong>< / div>< / td>

< td>< input type =" text" ;名称= QUOT; CONTACTNAME" value ="。$ row [''contactName'']。">< / td>

< / tr>

< tr>

< td>< font color ="#000000" face =" Verdana">联系电话号码< font color ="#FF0000"> *< / font>< / font>< / td>

< td>< ; div align =" center">< strong>:< / strong>< / div>< / td>

< td>< input name =" contactNum" ;类型= QUOT;文本" MAXLENGTH = QUOT 11 QUOT;值= QUOT; $行[ '' contactNaum '']"。>< / TD>

将/ TR>

将TR>

< td>< font color ="#000000" face =" Verdana">传真< / font>< / td>

< td>< div align =" center">< strong>:< / strong> ;< / div>< / td>

< td>< input name =" fax"类型= QUOT;文本" MAXLENGTH = QUOT 11 QUOT; value ="。$ row [''fax'']。">< / td>

< / tr>

< tr>

< td>< font color ="#000000" face =" Verdana">联系地址< font color ="#FF0000"> *< / font>< / font>< / td>

< td>< ; div align =" center">< strong>:< / strong>< / div>< / td>

< td>< textarea name =" contactAdd" ; COLS = QUOT; 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"类型= QUOT;文本" MAXLENGTH = QUOT; 50" value ="。$ row [''city'']。">< / td>

< / tr>

< tr>

< td>< font color ="#000000" face =" Verdana">邮政编码< / font>< / td>

< td>< div align =" center">< strong>:< / strong> ;< / div>< / td>

< td>< input name =" postcode"类型= QUOT;文本" MAXLENGTH = QUOT; 5英寸值= QUOT; $行[ 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"命名= QUOT;状态" 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"类型= QUOT;文本" value ="。$ row [''country'']。">< / td>

< / tr>

< tr>

< td>< font color ="#000000" face =" Verdana">说明< / font>< / td>

< td>< div align =" center">< strong>:< / strong> ;< / div>< / td>

< td>< textarea name =" description" COLS = QUOT; 33" rows =" 3">"。$ row [''description'']。"< / textarea>< / td>

< / tr>

< / tr>

< / table>

< p>

< / div>

< p>

< input type =''hidden''name =''company_ID''value ="。$ _ GET [''company_ID'']。 ;>

<输入名称=''提交''type =''submit''id =''submit''value =''更新个人资料''>

< / p>

< / div>

<?

} else {//无法获取信息。

print''< p>无法检索条目,因为:< b>''。mysql_error()。 '' < / b取代。查询是$ query。< / p>'';

}

}其他{//没有ID设置

print'' < p>< b>您在使用此页面时一定犯了错误。< / b>< / p>'';

}

} //主IF的结尾。


mysql_close(); //关闭数据库连接。

?>


[/ PHP]

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]

推荐答案

_GET [''company_ID' '))){[/ PHP]


我的整个编码如下:

[PHP]<?php

error_reporting(E_ALL);

// ob_start();

session_start();


//连接到服务器并选择数据库
_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'','''')

或die(mysql_error());

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


conn)或死(mysql_error());


if(isset(
conn) or die(mysql_error());

if (isset(


这篇关于更新配置文件无法正常工作:注意:未定义的索引:company_ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆