Problem details: the onsubmit trigger event sends the form data to the relevant php for processing, but how can we avoid triggering the event when data is faulty? Functiondosubmit () {window. open (& #39; num3.php? Cf & #39; + window. form. cf. value + & #39; & amp; cf1 & #39; + window. form. cf1.value) ;}] phpjavascript
Problem details: the onsubmit trigger event sends the form data to the relevant php for processing, but how can we avoid triggering the event when data is faulty?
Function dosubmit () {window. open ('num3. php? Cf = '+ window. form. cf. value +' & cf1 = '+ window. form. cf1.value );}
Require_once ('appvars. php ');
Require_once ('varvars. php ');
If (isset ($ _ POST ['submit ']) {// 10th rows
$ Name = $ _ POST ['name'];
$ Score = $ _ POST ['score '];
$ St = $ _ FILES ['st'] ['name'];
$ St_type = $ _ FILES ['st'] ['type'];
$ St_size = $ _ FILES ['st'] ['size'];
$ Output_form = false;
If (empty ($ name) | empty ($ score) | empty ($ st ))
{
Echo 'something is wrong!
';
$ Output_form = true;
}
// 20th rows
Else {
If ($ st_type = 'image/GIF') | ($ st_type = 'image/jpeg ') | ($ st_type = 'image/pjeg ') | ($ st_type = 'image/png ') & ($ st_size> 0) & ($ st_size <= MAX_FILE_SIZE ))
{
If ($ _ FILES ['st'] ['error'] = 0 ){
$ Target = GW_UPLOADPATH. $ st;
// 30th rows
If (move_uploaded_file ($ _ FILES ['st'] ['tmp _ name'], $ target )){
$ Dbc = mysqli_connect (HOST, USER, PASSWORD, NAME );
$ St = $ _ FILES ['st'] ['name'];
$ Query = "insert into B (date, st, score, name )".
"VALUES (NOW (), '$ St',' $ score ',' $ name ')";
// 40th rows
Mysqli_query ($ dbc, $ query)
Or die ('uu ');
Echo 'you are success to add dates to mysql '.'
'; Echo 'name:'. $ Name .'
'; Echo 'Score:'. $ Score .'
'; Echo 'photo:'. ''; // 50th echo'Back to index page
';
// Clear the score datas
$ Name = "";
$ Score = "";
$ St = "";
Mysqli_close ($ dbc );
} // If (move_uploaded_f
Else
{
Echo $ _ FILES ['st'] ['error'];
Echo'
File Not moved !! '; // Row 60th
}
} // If ($ _ FILES ['st'] ['error']
Else
Echo 'There is something wrong to upload the file! Plese upload it agian .';
} // If ($ st_type = 'image/GIF'
Else echo'
The screen pic must be a GIF, JPEG, or PNG image and the file '. 'size must fit'. '(MAX_FILE_SIZE/1024)'. 'kb.
';
} // Else // 70th rows
// Try to delete the temporary screen shot image file.
@ Unlink ($ _ FILES ['st'] ['tmp _ name']);
} Else $ output_form = true;
If ($ output_form ){
?>
Your name:
Your score:
Your Photo:
Commodity transactions; commodity swaps;