I tried php to modify the function many times. I think the code is okay?

Source: Internet
Author: User
I tried php to modify the function many times. I think the code is okay? The offer. php code is as follows:
Include ("inc/conn. php ");
// Modify the password
$ Act = $ _ GET ["act"];
$ Offer = $ _ POST ["offer"];
If ($ act = 'edit ')
{
$ Id = $ _ POST ["id"];
$ Url = $ _ SERVER ['http _ referer'];
$ SQL = "update td set offer = '$ offer' where id = '$ ID '";
Mysql_query ($ SQL );
Echo "script alert ('review successful! '); Window. location. href =' ". $ url." '; script ";
}
?>


The code on the homepage is as follows: Session_start ();
Include ("inc/conn. php ");
?>



Recruitment-job search-Shanghai Yafei Talent Network



Include ("top. php ");
?>





















 












Enterprise Management Center
















Modify enterprise information
Publish recruitment
Recruitment Management
View posting resumes
Exit










 












$ Userid = $ _ SESSION ["userid"];
$ SQL = "select * from company where userid = '$ userid '";
$ Query = mysql_query ($ SQL );
$ Rs = mysql_fetch_assoc ($ query );
$ Com_id = $ rs ["com_id"];
Mysql_free_result ($ query );
?>

 






Reply to discussion (solution)

@ Mix up @ Zhao 4

The control named id is not displayed in your form.

@ Mix up @ Zhao 4


I only recommend that you learn to write logs and debug logs first.

@ Zhao 4 what should I do?

Okay! Even the C ++ experts like Zhao 4 have come to grab your job!

You have
$ Id = $ _ POST ["id"];
$ SQL = "update td set offer = '$ offer' where id = '$ ID '";

However, the form does not contain the nam = "id" control, so $ _ POST ["id"] does not exist at all.
The actual SQL command you run is update td set offer = '$ offer' where id =''
Generally, id is the primary key, and the primary key cannot be empty. So your SQL commands are not executed.

@ Xuzuning:


You have

Or

Is this a control?
No. how do I pass the value?

@ Xuzuning no wonder that I have read other people's code before. The modification is as follows, but it still cannot be modified. it is strange!


$ Userid = $ _ SESSION ["userid"];
$ SQL = "select * from company where userid = '$ userid '";
$ Query = mysql_query ($ SQL );
$ Rs = mysql_fetch_assoc ($ query );
$ Com_id = $ rs ["com_id"];
Mysql_free_result ($ query );
?>






 



@ Xuzuning off. The php code is as follows:
Include ("inc/conn. php ");
// Modify the password
$ Act = $ _ GET ["act"];
$ Offer = $ _ POST ["offer"];
If ($ act = 'edit ')
{
$ Id = $ _ POST ["id"];
$ Url = $ _ SERVER ['http _ referer'];
$ SQL = "update td set offer = '$ offer' where id = 'id '";
Mysql_query ($ SQL );
Echo "script alert ('review successful! '); Window. location. href =' ". $ url." '; script ";
}
?>

@ Xuzuning the warning window is successful again, that is, the value cannot be modified!

$ SQL = "update td set offer = '$ offer' where id = '$ ID '";
Echo $ SQL;
Mysql_query ($ SQL) or die (mysql_error ());

Print it out to see what the SQL is, whether the parameters are correct, and whether the execution is wrong.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.