This program is always unable to submit data in the generated interface, and always prompts that the information with the asterisk is not complete, but I have already filled in the complete information

Source: Internet
Author: User
This program is always unable to submit data in the generated interface. it always prompts that the information with the asterisk is not complete, but I have already completed this post and edited by jackbill43 at 15:09:41.

Php

Novice




Classroom addition/modification



Include_once ("base-class.php ");

// Create an sae database class
$ Mysql = new SaeMysql ();

// Obtain the classroom ID to be modified and input it
$ Class_id = intval ($ _ GET ["class_id"]);

// Obtain the Operation ID for input
$ Action = $ _ POST ["action"];
$ Action = string: un_script_code ($ action );
$ Action = string: un_html ($ action );

// Determine whether to modify the content. if the classroom ID is input, query the database to obtain all the content.
If ($ class_id)
{
$ Class_value = $ mysql-> getLine ("select * from class where class_id = $ class_id ");
If (! $ Class_value)
{
Echo "script alert ('none classroom '); history. back ();";
Exit;
}
}

// If the operation ID is obtained, enter or modify the operation ID.
If ($ action = "update ")
{
// Obtain the input data of the form
$ Old_class_id = $ _ POST ["class_id"];
$ Class_name = $ _ POST ["class_name"];
$ Class_number = $ _ POST ["class_number"];
$ Class_fid = $ _ POST ["class_fid"];
$ Class_status = $ _ POST ["class_status"];

// Filter incoming data
$ Old_class_id = intval ($ old_class_id );
$ Class_name = string: un_script_code ($ class_name );
$ Class_number = string: un_script_code ($ class_number );
$ Class_fid = intval ($ class_fid );
$ Class_status = intval ($ class_status );

// Check Required items
If (! $ Class_name |! $ Class_number |! $ Roster_status)
{
Echo "script" alert ('The form is not complete, and an asterisk is required! '); History. back ();";
Exit;
}



// Default parameter
$ Nowtime = date ("Y/m/d H: I: s", time ());
// If it is modified
If ($ old_class_id)
{

$ SQL = "update class set
Class_name = '$ class_name ',
Class_number = '$ class_number ',
Class_fid = '$ class_fid ',
Class_status = '$ class_status ',
Edittime = '$ nowtime'
Where class_id = $ old_class_id ";
$ Mysql-> runSql ($ SQL );
}
Else
{
// Add
$ SQL = "insert into class
(Class_name, class_number, class_fid, class_status, addtime, edittime, status)
Values
('$ Class_name', '$ class_number', '$ class_status', '$ class_fid', '$ nowtime', '$ nowtime', 1 )";
$ Mysql-> runSql ($ SQL );

}
If ($ mysql-> errno ()! = 0)
{
Echo "script" alert ('". $ mysql-> errmsg ()."'); history. back ();";
Exit;
}
Else
{
Echo "script" alert ('Operation successful! '); Location = 'roster _ add. php? Class_id = $ old_class_id ';";
Exit;
}

}

// Obtain all teaching buildings
$ Building_list = $ mysql-> getData ("select building_name, building_id from building where status = 1 order by building_fid asc ");

?>

Classroom addition/modification return>

An asterisk is required.






Reply to discussion (solution)

If (! $ Class_name |! $ Class_number |! $ Roster_status) {echo "script" alert (the 'form is not complete and an asterisk is required! '); History. back ();"; Exit ;}

Where is $ roster_status defined and assigned? The code you posted does not include any related fields in the form on the page. This will certainly trigger this verification.

If (! $ Class_name |! $ Class_number |! $ Roster_status) {echo "script" alert (the 'form is not complete and an asterisk is required! '); History. back ();"; Exit ;}

Where is $ roster_status defined and assigned? The code you posted does not include any related fields in the form on the page. This will certainly trigger this verification. but there will still be problems after the change, is there any problem?

Var_dump ($ _ POST );


If (! $ Class_name |! $ Class_number |! $ Roster_status) {echo "script" alert (the 'form is not complete and an asterisk is required! '); History. back ();"; Exit ;}

Where is $ roster_status defined and assigned? The code you posted does not include any related fields in the form on the page. This will certainly trigger this verification. but there will still be problems after the change, is there any problem?
How did you change it?



If (! $ Class_name |! $ Class_number |! $ Roster_status) {echo "script" alert (the 'form is not complete and an asterisk is required! '); History. back ();"; Exit ;}

Where is $ roster_status defined and assigned? The code you posted does not include any related fields in the form on the page. This will certainly trigger this verification. but there will still be problems after the change, is there any problem?
How did you change it to the previously defined class_status?

Var_dump ($ _ POST); for details

1. $ _ POST is a variable that stores data submitted from the form using the post method. var_dump is used to print the internal structure of the variable and check whether the class_status is submitted by the form, if yes, what is the value?
2.

                            Select classroom status                Value = "0"> idle                Value = "1"> course available            

This place. The value of the option "classroom status" and "idle" is both 0, which is unreasonable. If you select these two states, the class_status submitted by the form is 0 ,! When the logic non-operator calculates 0, the result is the same as true, so an error is triggered.
Related Article

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.